by Ryan Chandler
This package provides a simple repeater field for Filament that lets you repeat a single field with a minimal UI.
This field behaves like other Filament fields and can be used with all three packages (tables, forms and admin).
use RyanChandler\FilamentSimpleRepeater\SimpleRepeater; protected function getFormSchema(): array{ return [ SimpleRepeater::make('emails') ->field( TextInput::make('email') ->required() ->email() ) ];}
The SimpleRepeater::field()
method accepts any object that extends the Filament\Forms\Components\Field
class. It doesn't support repeating Grid
, Group
or Section
objects. That behaviour is better suited to Filament's own Repeater
field.
By default, the SimpleRepeater
will output 1 empty field when it has no value. If you would like to change this behaviour, use the SimpleRepeater::defaultItems()
method.
SimpleRepeater::make('emails') ->defaultItems(2) ->field( TextInput::make('email') ->required() ->email() )
The field will now show 2 inputs by default.
By default, all items can be deleted in a similar fashion to Filament's own Repeater
.
To disable this behaviour, call the SimpleRepeater::disableItemDeletion()
method.
SimpleRepeater::make('emails') ->disableItemDeletion()
By default, all items can be moved / sorted using with drag and drop if there is more than 1 item.
To disable this behaviour, call the SimpleRepeater::disableItemMovement()
method.
SimpleRepeater::make('emails') ->disableItemMovement()