[TYPO3-mvc] form: problem updating a related object to empty (with solution)

Stefano Cecere scecere at krur.com
Thu Feb 7 13:59:06 CET 2013


hi. on 4.7

via Fluid Form. i have a form edit for $office with a simple selector to 
update a related object $country:

$office->country (n:1 relation)

if i select a $country with select id > 0 , the update method works 
perfeclty

otherwise, if is select "0" -- no country --
the update method fails to update, and keeps the previous value!!


my dirty solution has been to check the $arguments in the update 
method.. like:

public function updateAction(Domain_Model_office $office) {
	// hack to delete empty related objects
	$args = $this->request->getArguments();
	if (intval($args['office']['country']) == 0) {
		$office->setCountry(0);
	}
	$this->officeRepository->update($office);



did i miss anything?
is this a common procedure?

strange isn't it?



-- 

-- --- ----- -------

Stefano Cecere
KRUR studio - http://krur.com


More information about the TYPO3-project-typo3v4mvc mailing list