[TYPO3-mvc] How to unselect an n:1 related record with extbase/fluid?

Dirk Wenzel wenzel at webfox03.de
Tue Jun 11 21:53:45 CEST 2013


Hi Roland,
I guess that your form calls an add or update action when submitted. So 
when submitting a value of 0 your action might silently fail since no 
record with this uid exists.

You could check for this value in the action an then remove/unset any 
existing category value (perhaps by forwarding to a remove action).
IMHO it would be cleaner to simply add a remove button.

For me 'Please select' means 'nothing has been selected'. Therefore I 
would'n expect any modification...

Regards
Dirk

Am 06.06.13 08:54, schrieb Roland:
> hi everybody,
>
> my domain model has a Product and a Category which are n:1 related.
>
> a product can have 0 to 1 categories. a frontend user can select a
> category for a product via select box. this select box is generated via
> <f:format.select />.
>
> i added a "please select" option to the select box with the help of this
> snippet in my controller:
>
> --- php ---
> $this->view->assign('categories', array_merge(array(0 => 'Please
> select'), $this->categoryRepository->findAll()->toArray());
> --- /php ---
>
> if a frontend user selects one of the categories via select box and
> submits the form the update action successfully saves this category for
> the product.
>
> so far so good.
>
> problem: if a frontend user selects the "please select" option via
> select box and submits the form the previous selectd category is still
> associated with the category instead of removing this category from the
> product. interestingly no error message is displayed.
>
> question: how can i achive that a frontend user can unselect a
> associated category of a product?
>
> kind regards
>
> roland


More information about the TYPO3-project-typo3v4mvc mailing list