[TYPO3-mvc] form.select add empty option

Claus Due claus at wildside.dk
Mon Aug 29 19:28:09 CEST 2011


Hi Stefan,

I have very recently submitted a patch for Fluid which will (if merged) allow you to exclude the "options" argument and manually add <optgroup> and <option> tags inside the <select> while still preserving the form's __hmac value. If you need it quickly you can find it in the extension "fed" [1] or you can wait for 1.4 / 4.6 which I hope will include the patch :)

Alternatively you might prefer this:

<f:form.select options="{f:if(condition: themes, then: themes, else: {mylabel: 'MyValue'})" />

Which, of course, only uses the placeholder if your {themes} variable does not contain options or is not defined/passed in the template :)

[1] http://fedext.net/viewhelpers/form/select/

Cheers,
Claus Due

PS: the SelectViewHelper does add an empty option for valid output when no options are given, but unfortunately you cannot specify what the option should contain (both value and label will be empty strings).


On Aug 29, 2011, at 6:50 PM, Stefan Frömken wrote:

> Hello MVC-Team,
> 
> I want to add a simple empty option to form.select. The result should look like this:
> 
> <select ...>
> <option value="">--</option>
> ...
> </select>
> 
> I tried it this way...but it don't works:
> 
> <f:form.select options="{themes}" optionValueField="uid" optionLabelField="name" name="theme" value="--">
> 	<option value="">--</option>
> </f:form.select>
> 
> Any other ideas?
> 
> Stefan
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc



More information about the TYPO3-project-typo3v4mvc mailing list