6

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" />
Daniel
  • 6,916
  • 2
  • 36
  • 47
Cold_Class
  • 3,214
  • 4
  • 39
  • 82
  • I don't think f:form.textarea has this property . But you can implement the same thing using an "onclick" attribute.https://fluidtypo3.org/viewhelpers/fluid/master/Form/TextareaViewHelper.html – Siva Jul 03 '15 at 08:59

1 Answers1

10

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.

Daniel
  • 6,916
  • 2
  • 36
  • 47
  • If you want multiple Parameters use the following notation additionalAttributes="{required: 'required',maxLength:'100'}" – Welsh King Jul 22 '19 at 11:10