How to make Typo3 Fluid produce <option val="123" selected> and not <option val="123" selected="selected">?

Viewed 496

I'm creating a fluid form <select> box. Making an option pre-selected results in output 1.

1.  <option value="x" selected="selected"> Option text </option>

Is there a way to make the output instead render like this?

2.  <option value="x" selected> Option text </option>

I'm using Typo3 with the mdBootstrap material design framework, and its javascript requires format 2.

I've tried both the automatic generation of options and preselected options

<f:form.select name="mySelectBox" options="{selectOptions}" value="{optionSelected}"/>

and the manual format with additionalAttributes

<f:form.select name="mySelectBox">
   <f:for each="{selectOptions}" as="optionText" key="optionVal">
       <f:if condition="{optionSelected}=={optionVal}">
           <f:then><f:form.select.option value="{optionVal}" additionalAttributes="{selected:true}">{optionText}</f:form.select.option></f:then>
           <f:else><f:form.select.option value="{optionVal}">{optionText}</f:form.select.option></f:else>
       </f:if>
   </f:for>
</f:form.select>

But I can't set additionalAttributes without using key:data pairs, which results in the output of

selected=""

not

selected

Any kind person got any ideas please? Thanks for your time reading this.

0 Answers
Related