Saving null while disabling a select field
Hello there, I am using a select field. When the admin is logged in, admin can choose a user. However, for a regular user login, they cannot choose a user. Instead, I am passing the logged-in username with the 'disabled' attribute. But when I am saving the record, it is becoming null. Please help me to fix this issue.
code
Select::make('user_name')
->options($users)
->disabled($userIsUser)
->default($userIsUser ? $loggedInUserName : '')
->searchable()
->required(!$userIsUser),
Solution:Jump to solution
Disabled fields aren't saved to DB. Use
mutateFormDataBeforeSave()
to modify data before saving it.
https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-saving...2 Replies
Solution
Disabled fields aren't saved to DB. Use
mutateFormDataBeforeSave()
to modify data before saving it.
https://filamentphp.com/docs/3.x/panels/resources/editing-records#customizing-data-before-savingThank you it is working fineš¤©