TYPO3 fluid: <option> with dynamic selected attribute

raw

fluid.html

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<html data-namespace-typo3-fluid="true"
    xmlns="http://www.w3.org/1999/xhtml"
    xmlns:f="http://typo3.org/ns/TYPO3/Fluid/ViewHelpers"
    xmlns:v="http://typo3.org/ns/FluidTYPO3/Vhs/ViewHelpers"
>
 
    <f:for each="{options}" as="optionObject">
        <f:variable name="optionAttributes" value="{value: optionObject.value}"/>
        <f:if condition="{optionObject.isSelected}">
            <v:variable.set name="optionAttributes.selected" value="selected"/>
        </f:if>
        <v:tag name="option" additionalAttributes="{optionAttributes}">
            {optionObject.label}
        </v:tag>
    </f:for>
 
</html>
 
Christian Weiske Christian Weiske
owner

History