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

Henjo Hoeksma | Stylence me at henjohoeksma.nl
Fri Feb 8 02:35:39 CET 2013


Hi Stefano,

did you debug the contents of the property on your setter method in your
model?
I would do a check there to see if it is empty or not...

Kind regards,

Henjo

Problems are small because we learned how to deal with them.
Problems are big because we need to learn how to deal with them.


On Thu, Feb 7, 2013 at 1:59 PM, Stefano Cecere <scecere at krur.com> wrote:

> 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
> ______________________________**_________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc@**lists.typo3.org<TYPO3-project-typo3v4mvc at lists.typo3.org>
> http://lists.typo3.org/cgi-**bin/mailman/listinfo/typo3-**
> project-typo3v4mvc<http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc>
>


More information about the TYPO3-project-typo3v4mvc mailing list