[TYPO3-mvc] form.select add empty option

Stefan Frömken firma at sfroemken.de
Tue Aug 30 09:20:39 CEST 2011


Thank you Claus,

for now toArray() is a good start.
For later I think a new option "addEmpty" in select-ViewHelper would be 
perfect. But your idea is a little bit better, because you can combine 
many selfdefined options with the options of the array.

Stefan

Am 29.08.2011 19:28, schrieb Claus Due:
> 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