[TYPO3-mvc] f:form.select is not saved

Christian Kartnig office at hahnepeter.de
Sat Mar 12 10:56:48 CET 2011


Hi Again!

Now, I already found out, that a single select (multiple=false) attaches 
the object in 1:1 relationships, but the uid of the object is required 
in order to get saved correctly.

In n:1 relationships (which are according to the extbase book best 
realized by an n:m relationship having maxitems set to 1) the single 
select doesn't work out at all, because in the name of the form element, 
the [] indicating a new array element is missing.
When I add this [] in the Viewhelper, the object is saved correctly.

IMHO these are two bugs. Can anyone please confirm or explain that 
behaviour to me? If someone confirms, I will file the bugs.

Please answer, before I go insane talking to myself on this list...

best regards,
Christian






Am 11.03.2011 13:24, schrieb Christian Kartnig:
> 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