[FLOW3-general] Fluid: preselection with a multiple form.select with a M:N relation
Ivan Ruiz Gallego
ivan at loglan.net
Wed Nov 23 08:55:16 CET 2011
Hi Matthias,
If you want to preselect one of the select options you will need in most
cases to set the attribute value to that object. So something like this:
<f:form.select property="categories" options="{allCategories}"
value="{preselectedCategory}" />
If the option to be preselected results from from validation, FLOW3 will
preselect it. So in that case you don't need to set the value.
Regards,
Ivan.
On 18.11.2011 15:13, Matthias Habegger wrote:
> Hallo,
>
> I have a M:N relation between my two models "book" and "category".
>
>
> Now I try to create a multiple select with the SelectViewHelper like that:
> --
> <f:form.select property="categories" options="{categories}"
> optionLabelField="name" multiple="multiple" size="7" />
> --
>
>
> {categories} is a variable assigned in the controller.
> --
> $this->view->assign('categories', $this->categoryRepository->findAll());
> --
> that works fine, all, categories are shown in the select.
>
>
> The problem is, that none of my preselected categories are selected.
>
> The html output looks like that:
> --
> <input type="hidden" name="book[categories]" value="" />
> <select id="categories" multiple="multiple" size="7"
> name="book[categories][]">
> <option value="0bc305ec-8aff-4fa8-bdeb-476d7c21c841">Novels</option>
> <option value="8c2221e3-a3fd-4ce2-8f7e-66aac9eed5f5">Second
> Category</option>
> <option value="c1ca0c2d-08c4-4b22-b9c7-69bbd42de840">Third
> category</option>
> </select>
> --
>
>
> What shall I do to get the preselection work
>
> Greetings
> Matthias
More information about the FLOW3-general
mailing list