Select field default value
Hi, Im having trouble with data editing. When I click 'Edit' on a row, the 'region' select field should show the default value, but it keeps showing 'Select an option' instead. What am I doing wrong?
Solution:Jump to solution
Thank you! it solved my issue, for anyone asking about this, I added the mutateFormDataBeforeFill function on the Edit page ```php
protected function mutateFormDataBeforeFill(array $data): array
{
$data['region'] = Area::find($data['area_id'])->region->id;
...
3 Replies
Default only works on create pages. It doesn’t make sense in the context of an edit page as the value should have been set by then.
You can use lifecycle hooks like
mutateFormDataBeforeFill
(or similar naming) to set default values.Solution
Thank you! it solved my issue, for anyone asking about this, I added the mutateFormDataBeforeFill function on the Edit page