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

Roland most.wanted at gmx.at
Thu Jun 6 08:54:02 CEST 2013


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