Create Options Forms on a Select
Hello how can i create an option Forms on my non-relationship Select :
Forms\Components\Repeater::make('userFonctions')
->relationship()
->schema([
Forms\Components\Select::make('fonction_id')
->label('Fonction')
->options(Fonction::query()->pluck('name', 'id'))
->required()
->columnSpan([
'md' => 5,
])
->searchable()
->createOptionForm([
Forms\Components\TextInput::make('name')
->label('nom')
->unique(ignoreRecord: true)
->maxLength(255)
->required(),
Forms\Components\TextInput::make('diminutif')
->label('Abréviation')
->unique(ignoreRecord: true)
->maxLength(255)
->required(),
]),
6 Replies
Same way, but I think you need to manually save it. I think there is a
->createOptionUsing()
method or similar to modify the behaviour
Also please use triple backticks to format the code (seems like you used single backticks). It's not very readableok ty
eg:
@Dennis Koch plz do you have any example
@DrByte
Looks like this is how the Form's Select component does it "with" a relationship: https://github.com/filamentphp/filament/blob/751c24beb998e334803701ed48a379031256fbaf/packages/forms/src/Components/Select.php#L969-L977
GitHub
filament/packages/forms/src/Components/Select.php at 751c24beb998e3...
A collection of beautiful full-stack components for Laravel. The perfect starting point for your next app. Using Livewire, Alpine.js and Tailwind CSS. - filamentphp/filament
Merci