Radio default not working
I have a Radio input in my form and using default isn't working for some reason:
Once I select an option everything works as expected, but on page load the default isn't there.
Solution:Jump to solution
Your comment got me on the right track. Found a github answer that indicated I need to set the value of the
access_option
array key before the form is filled, so I added this to my EditUser resource and now its working as expected:
```
protected function mutateFormDataBeforeFill(array $data): array
{...6 Replies
Does it work on creation form but not the edit form
@toeknee It's just on the UserResource class
but I guess it's when I'm editing a user.
when creating a new user, it has a default
Solution
Your comment got me on the right track. Found a github answer that indicated I need to set the value of the
access_option
array key before the form is filled, so I added this to my EditUser resource and now its working as expected:
thank you!
FYI. ->default() only works on create pages. On the edit page the form data is assumed to have already been saved with the default. That’s why you have to manually fill it.
in hindsight, that makes perfect sense, thank you!