[TYPO3-mvc] Persist multiple models through a form in fluid/extbase

Frank Gerards F.Gerards at esolut.de
Mon May 7 14:11:27 CEST 2012


Hi,

 

quick question:

 

I got a form with downloads. This downloads come from a model related to
the main model handled by the form and 

are authored via the backend. However, I want to persist the main model
with the chosen downloads in the createAction.

 

To my understanding, I need a new model i.e. called "downloadPersisted",
which also has a relation to the main Model (this is

"downloadPersisted" is a property of Type ObjectStorage in the main
model).

 

In the Partial I do a for-loop over the attached "downloads" and list
them with a checkbox in front of it.

Now comes the tricky part and I asked myself "How do I dynamically
"spawn" "downloadPersisted" models when the form is submitted ?

 

One way I tried was to return the chosen downloads as an array
"persistedDownloads" to the createAction in the controller,

which works fine. I then spawn a persistedDownload model for each array
item and attach it to the main model and as a last step persist the main
model to the repository - this also works fine.

 

My main question now is: do I have to "destroy" the persistedDownload
model after each loop to get a clean state or does extbase do that
automatically ? I know it works by now, but I wanted to get a better
understanding on how extbases' persistence layer works...

 

PS: TYPO3 4.6 here with corresponding extbase version

 



More information about the TYPO3-project-typo3v4mvc mailing list