[TYPO3-mvc] edit multiple objects in one form

Johannes C. Schulz - EnzephaloN IT-Solutions info at enzephalon.de
Thu Mar 8 11:22:31 CET 2012


Claus wrote:
You must initialize your ObjectStorage-type properties in your Models
constructor.

Dear Claus

Yes, I know. In my "person"-model the constructor looks like:
	/**
	* The constructor of this Accreditation
	*
	* @return void
	*/
	public function __construct(){
		$this->initStorageObjects();
	}
	/**
	 * Initializes all Tx_Extbase_Persistence_ObjectStorage properties.
	 *
	 * @return void
	 */
	protected function initStorageObjects(){
		$this->passport = new
Tx_Extbase_Persistence_ObjectStorage();
	}
But I think, the construct isn't called, cause I get the person-object by
$this->personRepository->findOneByProperty(property) and not by accessing
the parent object.
Or is there something wrong with my construct?
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
Johannes C. Schulz - EnzephaloN IT-Solutions
Gesendet: Donnerstag, 8. März 2012 10:29
An: 'TYPO3 v4 MVC project'
Betreff: Re: [TYPO3-mvc] edit multiple objects in one form

Hello Lorenz

One problem left with your hacky-workaround:
All is fine if I do an setProperty inside the foreach. But if I try to make
an addProperty I get an  "Call to a member function attach() on a
non-object"-error.
Do you have an idea how to fix this?
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: Dienstag, 21. Februar 2012 10:14
An: typo3-project-typo3v4mvc at lists.typo3.org
Betreff: Re: [TYPO3-mvc] edit multiple objects in one form

Hi Johannes

Are you sure that your $personObject is really just one object? Seems that
you didn't use a "findOneByXXX" method but a "findXXX" method...

Best regards,

Lorenz

Am 21.02.2012 09:31, schrieb Johannes C. Schulz - EnzephaloN IT-Solutions:
> Hello Lorenz
> I tried your workaround to solve a problem similar to yours, but I get 
> an error " Fatal error: Call to undefined method
> Tx_Extbase_Persistence_QueryResult::setAccepted() in 
> F:\Kunden\xampp\htdocs\psoa\typo3conf\ext\psoa_accredit\Classes\Contro
> ller\B
> ackendController.php on line 133".
> 133: if(!$person['denied']) $personObject->setAccepted(1); Do you have 
> an idea about that?
> 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: Donnerstag, 17. November 2011 17:37
> An: typo3-project-typo3v4mvc at lists.typo3.org
> Betreff: Re: [TYPO3-mvc] edit multiple objects in one form
>
> Hi everyone
>
> If anyone else is interested, I just to let you know about the 
> approach/workaround I took in the meantime:
>
> I iterate over all related objects (here: artistical works) of a user 
> and create the fields like this:
>
> <f:form.textfield name="work[{work.uid}][creationyear]"
> value="{work.creationyear}" />
>
> I submit the form to the multiUpdateAction in my controller that 
> iterates on the request and updates the value for each object:
>
> $works = $this->request->getArgument('work');
> foreach ($works as $uid =>  $work) {
> 	$work['uid'] = $uid;
> 	$workObject = $this->workRepository->findByUid($uid);
> 	$workObject->setTitle($work['title']);
> 	$workObject->setCreationyear($work['creationyear']);
> 	$workObject->setDescription($work['description']);
> 	$workObject->setVisibility($work['visibility']);
> 	$workObject->setSorting($work['sorting']);
> }
>
> Might be a bit hacky, but works. I'm using it for an IRRE-like 
> frontend where the user can sort and edit his works in a JQuery 
> sortable
accordion.
>
> Best regards,
>
> Lorenz
>
> Am 17.11.2011 15:14, schrieb Lorenz Ulrich:
> _______________________________________________
> 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


_______________________________________________
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