Skip to content

Releases: formers/former

5.1.1

18 Jul 20:09
7f2e848

Choose a tag to compare

This release is thanks to work by @AleksandrSpicyn - thank you!

  • Bug fix for selection logic for Select and Checkable fields (#617)

Can now build dynamic radio() and checkbox() groups using collection-driven definitions, without requiring external transformation logic. (TODO for anyone interested: document some examples for this)

Select (Former\Form\Fields\Select)

  • Fixed an edge case where previously selected values could persist due to missing state reset:
  • Added clearSelected() method to ensure no stale selected attributes remain before rendering.
  • Improved type-safety when comparing numeric values
  • Enhanced addOption() to support optgroup with nested options that include attributes (not just text).
  • Preserved backward compatibility by retaining existing behavior unless extra attributes are passed.

Checkable (Former\Traits\Checkable)

  • Restored and improved the fromQuery() method:
  • Now supports passing closures for $text and $attributes, consistent with Select::fromQuery().
  • Refactored internal items() method to accept Eloquent/Fluent collections
  • Now matches behavior of Select, including array_flip() fallback for simpler usage.

5.1.0

11 Mar 09:34
5.1.0
4f8f5b0

Choose a tag to compare

  • Allow installation on Laravel 12
  • Fixes for PHP 8.4 deprecations

5.0.0

03 Jun 09:03
5.0.0
e4067be

Choose a tag to compare

With thanks to the work @tortuetorche 2 years ago to get this started! ❤️

Added

  • Add CSS class to the label of a group, with the addLabelClass() method (#604)

  • Bootstrap 5 support

  • Add Bootstrap 5 floating labels via the floatingLabel() method for <input>, <select> and <textarea> tags

    NOTE: You need to use floating label elements with a vertical_open Former instance!

    Usage with Laravel:

    {!! Former::vertical_open() !!}
        {!!
            Former::text('test-floating-label-ok')
                ->placeholder('dummy placeholder')
                ->floatingLabel()
        !!}
        {!!
            Former::select('users-floating-label')
                ->options(['User One', 'User Two', 'User Three'])
                ->placeholder('Select placeholder')
                ->floatingLabel()
        !!}
        {!!
            Former::textarea('textarea-floating-label')
                ->floatingLabel()
                ->placeholder('dummy placeholder')
        !!}
    {!! Former::close() !!}
    
    {!! Former::vertical_open() !!}
        <div class="row">
            <div class="col">
                {!!
                    Former::text('test-floating-label-one')
                        ->placeholder('dummy placeholder')
                        ->floatingLabel()
                !!}
            </div>
            <div class="col">
                {!!
                    Former::text('test-floating-label-two')
                        ->placeholder('dummy placeholder')
                        ->floatingLabel()
                !!}
            </div>
        </div>
    {!! Former::close() !!}
  • Add the switch markup which is a custom checkbox for Bootstrap 5

    Some use cases with Laravel:

    {!!
        Former::switch('valid_switch_ok')
            ->text('Valid switch OK')
    !!}
    
    {!!
        Former::switches('valid_inline_switches_ok')
            ->switches('first', 'second', 'third', 'fourth')
            ->inline()
    !!}
  • Add removeGroupClass() and removeLabelClass() methods

    Usage with Laravel:

    {!!
        Former::text('test')
            ->removeGroupClass('row')
            ->removeLabelClass('foo')
    !!}

Changed

  • Better Bootstrap 4 support
  • Breaking change: Escape HTML value of plaintext field by default (#605)
    You can disable this new behavior with the escape_plaintext_value former config option set to false.
    In your former config file config/former.php, you can enable or disable this feature:
<?php

return [
    //...

    // Whether Former should escape HTML tags of 'plaintext' fields
    // Enabled by default
    //
    // Instead of disabled this option,
    // you should use the 'HtmlString' class:
    //  Former::plaintext('text')
    //      ->forceValue(
    //          new Illuminate\Support\HtmlString('<b>HTML data</b>')
    //      )
    'escape_plaintext_value' => true,

    //...
];

4.9.0

22 Mar 11:33
4.9.0
229e4e0

Choose a tag to compare

  • Allow installation on Laravel 11

4.8.1

24 Jan 10:25
4.8.1
e0e4b4f

Choose a tag to compare

  • Fixed null value deprecation (#613)

4.8.0

23 Mar 09:15
4.8.0
5c595b8

Choose a tag to compare

  • Allow installation on Laravel 10

4.7.0

17 Feb 11:54
4.7.0
9a88328

Choose a tag to compare

  • Allow installation on Laravel 9

Bootstrap 5.0 support

02 Jun 09:22
45d37ae

Choose a tag to compare

Bootstrap 5.0 support Pre-release
Pre-release

Added

  • Add Bootstrap 5 floating labels via the floatingLabel() method for <input>, <select> and <textarea> tags

    NOTE: You need to use floating label elements with a vertical_open Former instance!

    Usage with Laravel:

    {!! Former::vertical_open() !!}
        {!!
            Former::text('test-floating-label-ok')
                ->placeholder('dummy placeholder')
                ->floatingLabel()
        !!}
        {!!
            Former::select('users-floating-label')
                ->options(['User One', 'User Two', 'User Three'])
                ->placeholder('Select placeholder')
                ->floatingLabel()
        !!}
        {!!
            Former::textarea('textarea-floating-label')
                ->floatingLabel()
                ->placeholder('dummy placeholder')
        !!}
    {!! Former::close() !!}
    
    {!! Former::vertical_open() !!}
        <div class="row">
            <div class="col">
                {!!
                    Former::text('test-floating-label-one')
                        ->placeholder('dummy placeholder')
                        ->floatingLabel()
                !!}
            </div>
            <div class="col">
                {!!
                    Former::text('test-floating-label-two')
                        ->placeholder('dummy placeholder')
                        ->floatingLabel()
                !!}
            </div>
        </div>
    {!! Former::close() !!}
  • Add the switch markup which is a custom checkbox for Bootstrap 5

    Some use cases with Laravel:

    {!!
        Former::switch('valid_switch_ok')
            ->text('Valid switch OK')
    !!}
    
    {!!
        Former::switches('valid_inline_switches_ok')
            ->switches('first', 'second', 'third', 'fourth')
            ->inline()
    !!}
  • Add removeGroupClass() and removeLabelClass() methods

    Usage with Laravel:

    {!!
        Former::text('test')
            ->removeGroupClass('row')
            ->removeLabelClass('foo')
    !!}

    WARNING: There is a bug in the HTMLObject package!
    See my pull request for more info: Anahkiasen/html-object#34

Better Bootstrap 4 support and Former::plaintext() security fix

21 Jan 16:07
13a7d4e

Choose a tag to compare

Added

  • Add CSS class to the label of a group, with the addLabelClass() method (#604)

Changed

  • Better Bootstrap 4 support
  • Breaking change: Escape HTML value of plaintext field by default (#605)
    You can disable this new behavior with the escape_plaintext_value former config option set to false.
    In your former config file config/former.php, you can enable or disable this feature:
<?php

return [
    //...

    // Whether Former should escape HTML tags of 'plaintext' fields
    // Enabled by default
    //
    // Instead of disabled this option,
    // you should use the 'HtmlString' class:
    //  Former::plaintext('text')
    //      ->forceValue(
    //          new Illuminate\Support\HtmlString('<b>HTML data</b>')
    //      )
    'escape_plaintext_value' => true,

    //...
];

4.6.0

30 Nov 20:40
4.6.0
c5bcd07

Choose a tag to compare

  • Drop support for Laravel < 5.1.2 (if you need support for earlier Laravel version you can continue to use Former 4.4.x and lower)
  • Add support for PHP 8.0