[TYPO3-mvc] f:form.select is not saved
Christian Kartnig
office at hahnepeter.de
Fri Mar 11 13:24:45 CET 2011
Hi!
I just found out, that it works out if I use the uid of the country.
$country = $company->getCountry()->getUid();
$company->setCountry($country);
$this->companyRepository->update($company);
Why is this? Has it something todo with defining the relation 1:1?
*confused*
By the way, should I use a n:1 relationship (because, yes, one country
can have many companies, but it makes no difference on the company side,
does it?) ?
Can someone give me a hint how this works?
best regards,
Christian
Am 11.03.2011 10:49, schrieb Christian Kartnig:
> Hi all!
>
> I have a company entity (aggregate root) that has a relation to a
> country entity (aggregate root also), that i want to assign using a
> single selectbox. Everything works out fine, but the country value is
> not updated.
>
> This is my code:
>
> <f:form.select property="country" options="{countries}"
> optionValueField="uid" optionLabelField="name" />
>
> in the controller:
> public function updateAction(Tx_Top1001_Domain_Model_Company $company) {
> $this->companyRepository->update($company);
> $this->flashMessageContainer->add('Your Company was updated.');
> $this->redirect('list');
> }
>
> If I do a print_r of $company, the country is set to the right value,
> the old country is found in _cleanProperties:private. But this value is
> not saved by companyRepository->update($company);
>
> If I set the country manually (e.g. $company->setCountry(3)) before the
> companyRepository->update($company);, the value is saved.
>
> What am I doing wrong?
>
> Thanks for your help,
>
> Christian
More information about the TYPO3-project-typo3v4mvc
mailing list