Required "Select" forms component saving empty data.

- Create a select form component and make it required - Open the page and fill the rest of the form but keep the select empty (placeholder) - Save the form = it will give error to choose from the select - Now select any option and save again = the chosen option will not be saved - try to open the page again to update = you will see that the select has nothing chosen. Note: if I will open the form and and choose select option before trying to save in the first place = data will be saved without any issues. is this a bug, or am I doing something wrong
Forms\Components\Select::make('menu_section_id')
->relationship('menuSection', 'description')
->options($sectionOptions)
->default($defaultSection)
->required(),
Forms\Components\Select::make('menu_section_id')
->relationship('menuSection', 'description')
->options($sectionOptions)
->default($defaultSection)
->required(),
No description
2 Replies
Patrick Boivin
Patrick Boivin16mo ago
I see you have both ->relationship() and ->options(), not sure if that could be the issue.
moaaz_m_f
moaaz_m_fOP16mo ago
I actually was commenting one and trying the other but still that's why I added the default so to prevent this issue incase the user forgot to choose.

Did you find this page helpful?