[TYPO3-mvc] Fluid: form.select view helper and empty default item

Michael Staatz info at mduttlinger.de
Mon Feb 1 13:53:28 CET 2010


Am 01.02.2010 12:45, schrieb Susanne Moog:
> Hey everyone,
>
> I have a short question about the form.select view helper of fluid. How
> do you handle select boxes that should start with an empty item
> (optional attribute).
>
> I want to render something like
>
> <select name="category" size="1" id="category"><option value="">---</option>
> <option value="cat1">cat1</option>
> <option value="cat2">cat2</option>
> <option value="cat3">cat3</option>
> </select>
>
> I'm using the following code atm (with the categories as object) and am
> unsure how to get an empty object at the beginning:
>
> <f:form.select property="category" options="{categories}"
> optionLabelField="name" size="1" id="category" />
>
> Thanks for any help,
>
> Susanne

You can try something like:

$tempCategory = new Tx_MyExtname_Domain_Model_Category();
$tempCategory->setCategorieName('---');

...
... Dont' know what your model looks like!! and what has to come here
...

$categories = array_merge(array($tempCategory), 
$yourCategorieRepository->findAll());

greets Michael


More information about the TYPO3-project-typo3v4mvc mailing list