[TYPO3-mvc] Fluid - Setting an attribute in viewHelper by condition

Franz Koch typo3.RemoveForMessage at elements-net.de
Thu Aug 19 16:12:36 CEST 2010


Hey,

> i wonder if it is possible to set a viewhelper attribute by an inline
> if-Viewhelper condition.In the following example, i want to set the
> additionalAttribute "onchange: submit()" conditional by an object property:
>
> <f:form.checkBox name="name" value="value"
> additionalAttributes="{f:if(condition: {object.submitOnChange} then:
> '{onchange : 'submit()'}')}" />
> <f:form.checkBox name="name" value="value"
> additionalAttributes="{onchange : {f:if(condition:
> {object.submitOnChange} then: 'submit()')}}" />
>
> But both variants produce the error #1237900529: The argument
> "additionalAttributes" was registered with type "array", but is of type
> "string" in view helper "Tx_Fluid_ViewHelpers_Form_CheckboxViewHelper".
>
> Is there any posibility to do this?

yes it is, but the inline syntax is a bit tricky. You need to escape it 
correctly. IIRC your nested viewHelpers has to be in single quotes and 
single qoutes inside it have to be escaped then etc.

Try this - although I'm not sure it's correct.

<f:form.checkBox name="name" value="value" 
additionalAttributes="{onchange : '{f:if(condition: 
object.submitOnChange, then: \'submit()\')}'}" />
-- 
kind regards,
Franz Koch


More information about the TYPO3-project-typo3v4mvc mailing list