Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

TYPO3 Fluid - How To Make f:form.textarea Mandatory

I have text fields like this that will turn red and won't let you submit the form automatically if I put the property required on "1":

<f:form.textfield required="1" 
                  property="name" 
                  class="lcapp-formwidth"/>

Now I'm searching for the same in a textarea...the property required doesn't work here anymore...what would be the "best practice" to make it a required field just like the textfield?

<f:form.textarea property="story" 
                 rows="3" 
                 cols="7" 
                 class="lcapp-formwidth" />
like image 997
Cold_Class Avatar asked Jul 01 '15 18:07

Cold_Class


1 Answers

It is true, the TextareaViewHelper does not support the required attribute as an argument, but you can add any attribute to a fluid generated tag by using the additionalAttributes argument.

E.g.:

<f:form.textarea property="story" 
    rows="3" 
    cols="7" 
    class="lcapp-formwidth"
    additionalAttributes="{required: 'required'}" />

Notice how additionalAttributes expects an array notation, where the key is the name of the attribute.

like image 184
Daniel Avatar answered Oct 13 '22 07:10

Daniel