example select input with create option form
add this code
->createOptionAction(function (Action $action) {
$action->mutateFormDataUsing(function ($data) {
$data['team_id'] = Filament::getTenant()->id;
return $data;
});
return $action
->modalHeading('Create customer')
->modalSubmitActionLabel('Create customer')
->modalWidth('7xl');
})full code as below:
Forms\Components\Select::make('shop_customer_id')
->relationship('customer', 'name')
->searchable()
->required()
->preload()
->live(onBlur: true)
->createOptionForm([
self::customerForm(),
])
->createOptionAction(function (Action $action) {
$action->mutateFormDataUsing(function ($data) {
$data['team_id'] = Filament::getTenant()->id;
return $data;
});
return $action
->modalHeading('Create customer')
->modalSubmitActionLabel('Create customer')
->modalWidth('7xl');
})
->native(false),
Leave a Reply