Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
381 views
in Technique[技术] by (71.8m points)

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

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.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...