[TYPO3-mvc] How to edit (multiple) child-objects?

Johannes C. Schulz - EnzephaloN IT-Solutions info at enzephalon.de
Wed Mar 14 12:28:18 CET 2012


Hello list.
Damn! Me again - sorry! 
My editing of multiple child-objects only works if there is only one
child-object. If there are more than one, I get the "Call to a member
function attach() on a non-object"-error.
I attach the part from the controller-action, that should save the changes:
		$persons = $this->request->getArgument('person');
		foreach ($persons as $aid => $person) {
			$personObject =
$this->personRepository->findOneByAid($person['aid']);
			if($person['delete'] == 1){
				$accreditation->removePerson($personObject);
			}else{
				if($person['denied'] == 2){
					$personObject->setAccepted(1);
				}
				elseif($person['denied'] == 1){
					$personObject->setDenied(1);
				}
				if(!empty($person['exchangeticket']))
$personObject->setExchangeticket($person['exchangeticket']);
				if(!empty($person['passport'])){
					foreach ($person['passport'] as
$passport){
	
$personObject->addPassport($this->passportRepository->findOneByUid($passport
));
					}
				}
			}
		}
I think it's because extbase only writes data when reaching the redirect. If
I only have one $personObject it works, but if the foreach "creates" nore
than one it breaks. I tried to do a persistAll after addPassport(), but this
didn't help.
The array $persons (generated by fluid-form) looks completely ok, also it
looks good if I do a print_r on $personObject.
Do you have any ideas how to fix these problem?
Best regards
Johannes


-----Ursprüngliche Nachricht-----
Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
[mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag von
Lorenz Ulrich
Gesendet: Mittwoch, 14. März 2012 09:56
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: Re: [TYPO3-mvc] How to edit (multiple) child-objects?

Hi Johannes

Seems logical to me. If you set or get, you set/get a whole object storage
(one or many objects). If you add/remove, you just add/remove one object of
the corresponding type.

Best regards,

Lorenz

Am 14.03.2012 09:14, schrieb Johannes C. Schulz - EnzephaloN IT-Solutions:
> Hello Claus
>
> Thanks for your answer. I will keep this in mind.
> I solved the problem in an other way:
> The addPassport-function had not the correct annotation. It was 
> "@param Tx_Extbase_ObjectStorage<Tx_PsoaAccredit_Domain_Model_Passport
$passport"
> but needs to be "@param Tx_PsoaAccredit_Domain_Model_Passport $passport".
> After I changed this, it works fine!
> Do it right, if a setter has annotation "@param
Tx_Extbase_ObjectStorage..."
> and adder/remover have "@param Tx_MyExt_Domain_Model_...."?
>
> Best regards
> Johannes
>
> -----Ursprüngliche Nachricht-----
> Von: typo3-project-typo3v4mvc-bounces at lists.typo3.org
> [mailto:typo3-project-typo3v4mvc-bounces at lists.typo3.org] Im Auftrag 
> von Claus Due
> Gesendet: Dienstag, 13. März 2012 18:41
> An: TYPO3 v4 MVC project
> Betreff: Re: [TYPO3-mvc] How to edit (multiple) child-objects?
>
> Hi Johannes,
>
> Please excuse my short answer (in a bit of a hurry):
>
> If I remember correctly: use "persons.{iteration.index}.passport" as 
> property name. Remember to add iteration="iteration" to your f:for.
>
> --
> Cheers,
> Claus
> http://fedext.net
>
> On Mar 13, 2012, at 5:56 PM, Johannes C. Schulz - EnzephaloN 
> IT-Solutions
> wrote:
>
>> Doesn't anyone has an idea, how to solve this problem?
>
> _______________________________________________
> TYPO3-project-typo3v4mvc mailing list
> TYPO3-project-typo3v4mvc at lists.typo3.org
> http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4m
> vc
>
>

_______________________________________________
TYPO3-project-typo3v4mvc mailing list
TYPO3-project-typo3v4mvc at lists.typo3.org
http://lists.typo3.org/cgi-bin/mailman/listinfo/typo3-project-typo3v4mvc




More information about the TYPO3-project-typo3v4mvc mailing list