Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make "<f:form.select>" a mandatory field (required)?

Users are required to pick an option from this select:

<f:form.select name="role" options="{role}" optionLabelField="title" optionValueField="uid" size="4" />

The fluid select element has no required or minItems-Attribute. I don't want to check for missing arguments in the controller because the form is quite complex and I don't want to make users enter all the data again after $this->redirect("show").

I would prefer to have exactly the same implementation as with :

<f:form.textfield name="foo" required="true" />

which works like a charm. How would I do this?

like image 481
digijay Avatar asked Oct 25 '25 14:10

digijay


1 Answers

As Ghanshyam pointed out you have to add additionalAttributes="{required:'required'}" to the <f:form.select> element. It does not work with whitespace within the attribute value.

like image 95
digijay Avatar answered Oct 27 '25 05:10

digijay