Error getEditOptionActionFormData when using editOptionForm in Select without a relationship

Hello. I have a select:
Select::make('decedent_id')
Select::make('decedent_id')
with the createOptionForm() working correctly now, and I also need the user to be able to edit, so I added the code for the edit:
->editOptionForm([
DatePicker::make('date_of_death')
->displayFormat('d M Y')
->required()
->minDate(now()->subYears(120))
->maxDate(now()->subDays(1))
->label(__('date_of_death'))
->placeholder(__('date_of_death'))
->columnSpan(4),
])
->editOptionForm([
DatePicker::make('date_of_death')
->displayFormat('d M Y')
->required()
->minDate(now()->subYears(120))
->maxDate(now()->subDays(1))
->label(__('date_of_death'))
->placeholder(__('date_of_death'))
->columnSpan(4),
])
But when I select one existing data from the dropdown it thows the error: Filament\Forms\Components\Select::getEditOptionActionFormData(): Return value must be of type array, null returned Any ideas of how to solve this? I suppose it is not a problem to enable both the createOption and the editOption at the same time. Is it that way? Thanks.
9 Replies
toeknee
toeknee17mo ago
I am guessing youm need: editOptionActionFormData([ $data here? ]) this is a new feature I am not familiar with
Albert Lens
Albert LensOP17mo ago
Yes. I suppose it is something like that, but I have been trying blindly with no success. Any example could help, please.
toeknee
toeknee17mo ago
editOptionActionFormData(fn($record) => $record) ?
Albert Lens
Albert LensOP17mo ago
Nope. Already tried but no results.
toeknee
toeknee17mo ago
editOptionActionFormData(fn($record) => $record->toArray()) Can you provide your code I think I know hy
Albert Lens
Albert LensOP17mo ago
Someone helped me with the createOption https://discord.com/channels/883083792112300104/1148349791013703720 But with the same idea, edit is not working. If you go to definition on function getEditOptionActionFormData it expects an array and gets it from fillEditOptionActionFormUsing. I tried:
->fillEditOptionActionFormUsing(function ($record, $data) {
$person = Person::find($data['decedent_id']);
$person->fill($data);
$person->save();
return $person->id;
})
->fillEditOptionActionFormUsing(function ($record, $data) {
$person = Person::find($data['decedent_id']);
$person->fill($data);
$person->save();
return $person->id;
})
And error now is ==> An attempt was made to evaluate a closure for [Filament\Forms\Components\Select], but [$data] was unresolvable.
toeknee
toeknee17mo ago
The whole code, that's just a fill edit code.
Albert Lens
Albert LensOP17mo ago
The whole select field code is too long. A file is created but you can see:




Antoine
Antoine16mo ago
same problem. Have you resolve this bug ? An attempt was made to evaluate a closure for [App\Forms\Components\Select], but [$data] was unresolvable.

Did you find this page helpful?