[TYPO3-mvc] form.select add empty option

Stefano Cecere scecere at krur.com
Wed Mar 14 13:06:46 CET 2012


hi Claus

i tried to understand, from  
http://fedext.net/fed-viewhelpers/form/select-option.html
how to add an "empty" field before my objects arrays.. but could not :(

so i ended up with the ->toArray() solution (and then merging the 0 =>'--'  
in the controller before giving the array to Fluid

ciao
stefano


On Mon, 29 Aug 2011 19:28:09 +0200, Claus Due <claus at wildside.dk> wrote:

> 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
>


-- 
____    ___   __  _ ______________________

   Stefano Cecere
   KRUR studio


More information about the TYPO3-project-typo3v4mvc mailing list