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

1

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" />
Bharat answered 1/7, 2015 at 18:10 Comment(1)
I don't think f:form.textarea has this property . But you can implement the same thing using an "onclick" attribute.fluidtypo3.org/viewhelpers/fluid/master/Form/…Cytolysis
C
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.

Cornetist answered 5/7, 2015 at 12:7 Comment(1)
If you want multiple Parameters use the following notation additionalAttributes="{required: 'required',maxLength:'100'}"Toucan

© 2022 - 2024 — McMap. All rights reserved.