[TYPO3-mvc] adding n Objects from a single view
Daniel Kürner
daniel.kuerner at mmp-mierau.de
Fri Oct 14 16:49:26 CEST 2011
Dear all,
I have a class called "Dataset" and a class called "Tag". There is a 1:n
relationship betweeen both: One Dataset may
have many Tags. The Dataset has a $tags attribute of type
objectstorage<Tag>.
I am perfectly able to store one Tag within a newDataset. What I want to
achieve is, that the User may add multiple tags (for testing purposes 3)
within one view.
What I did is, I added 3 textboxes to my view:
<f:form.textbox name="tag1"/>
<f:form.textbox name="tag2"/>
<f:form.textbox name="tag3"/>
the submit leads to the createAction where I try the following:
$tag1 = $this->request->getArgument('tag1');
$tagOne = t3lib_div::makeInstance('Tx_CrcData_Domain_Model_Tag');
$tagOne->setTag($tag1);
$newDataset->addTag($tagOne);
$tag2 = $this->request->getArgument('tag2');
$tagTwo = t3lib_div::makeInstance('Tx_CrcData_Domain_Model_Tag');
$tagTwo->setTag($tag1);
$newDataset->addTag($tagTwo);
and so fourth.
But: Only one Tag Object is being persisted within the database. addTag()
should add all three instances to the Dataset Object ?!
Any ideas on why it doesn´t?
Big thanks
Daniel
More information about the TYPO3-project-typo3v4mvc
mailing list