F
Filament9mo ago
Wiebe

Select not filled after createOptionUsing

In V2 it worked fine but in V3 it doesnt. After submitting the form in the select, the option is visible in the select dropdown but the select goes to "select an option".
Select::make('location_id')
->label(__('manage.location'))
->options(fn() => $this->organisation->locations->pluck('label', 'id'))
->createOptionForm([
SingleLayout::make()->schema([
TextInput::make('name')->label(__('manage.name_location'))->required(),
TextInput::make('address')->label(__('manage.address')),
TextInput::make('zipcode')->label(__('manage.zipcode')),
TextInput::make('city')->label(__('manage.city'))->required(),
])
])->reactive()->createOptionUsing(function($data, Forms\Set $set){
$location = new Location();
$location->organisation_id = $this->organisation->id;
$location->fill($data);
$location->save();
$set('location_id', $location->id);
return $location->id;
}),
Select::make('location_id')
->label(__('manage.location'))
->options(fn() => $this->organisation->locations->pluck('label', 'id'))
->createOptionForm([
SingleLayout::make()->schema([
TextInput::make('name')->label(__('manage.name_location'))->required(),
TextInput::make('address')->label(__('manage.address')),
TextInput::make('zipcode')->label(__('manage.zipcode')),
TextInput::make('city')->label(__('manage.city'))->required(),
])
])->reactive()->createOptionUsing(function($data, Forms\Set $set){
$location = new Location();
$location->organisation_id = $this->organisation->id;
$location->fill($data);
$location->save();
$set('location_id', $location->id);
return $location->id;
}),
1 Reply
LeandroFerreira
LeandroFerreira9mo ago
try using ->searchable()