[Flow] How to update aggregates with a single form
Teo C.
mathaios76 at gmail.com
Sun Sep 22 22:51:20 CEST 2013
Thank you Frans,
basically "value="{bar.name}" is interfering in the correct creation of hidden fields. By leaving that out, Flow correctly pre-populates the existing object values, and creates the correct hidden fields.
Regards
Teo
Quote: Frans Saris (minifranske) wrote on Fri, 20 September 2013 16:17
----------------------------------------------------
> Hi,
>
> You have to provide the identifiers of the subitems in a hidden input field
> in your form.
>
> <f:form.hidden name="bars.{i.index}.__identifier" value="{bar.id}" />
>
> See also http://lists.typo3.org/pipermail/flow/2013-June/003909.html
>
> Gr. Frans
> Op 20 sep. 2013 15:35 schreef "Sil via" <silvia.conti at bluewin.ch> het
> volgende:
>
> > Hi,
> > I had exactly your problem and I didn't find any solution but using
> > repositories for each class. Does someone know how to manage editing of
> > aggregates properly? Are there examples?
> > Do I have maybe to delete the entire collection and re-create it again?
> >
> > Thanks
> > Sil via
> >
> > Quote: Ivan Ruiz Gallego wrote on Wed, 28 September 2011 16:12
> > ------------------------------**----------------------
> >
> >> Hi,
> >>
> >> I have a model Foo, which has a OneToMany association to a model Bar
> >> (both are entities, Foo and Bar build an aggregate, Foo is the aggregate
> >> root). Both Foo and Bar have a property $name. I create an instance of Foo,
> >> which is related to a given number of instances of Bar. This works fine, so
> >> far. My problem relates to the update of such an association.
> >>
> >> I have an update form, which looks like:
> >>
> >> <f:form action="update" object="{foo}" name="foo">
> >> Foo's name: <f:form.textbox property="name" value="{foo.name}"
> >> />
> >> <f:for each="{foo.bars}" as="bar" iteration="i">
> >> Bar's name: <f:form.textbox
> >> property="bars.{i.index}.name" value="{bar.name}" />
> >> </f:for>
> >> <f:form.submit value="submit" />
> >> </f:form>
> >>
> >> The controller action update looks like as simple as this:
> >>
> >> /**
> >> * Update a foo
> >> *
> >> * @param \Acme\MyPackage\Domain\Model\**Foo $foo Foo to update
> >> * @return void
> >> */
> >> public function updateAction(\Acme\MyPackage\**Domain\Model\Foo $foo) {
> >> $this->fooRepository->update($**foo);
> >> $this->flashMessageContainer->**add('foo updated');
> >> $this->redirect('index');
> >> }
> >>
> >> When I submit the form, FLOW3 doesn't update the bars which were already
> >> associated with the foo, but it create new ones. So if initially foo had 3
> >> bars, after updating it has 6. I've taken a look to the HTML code generated
> >> by Fluid and I can see that the identity of the Foo instance is there, but
> >> I see nothing related to the identity of the Bar instances.
> >>
> >> What am I missing? Maybe is something wrong in the Fluid template?
> >>
> >> Thanks,
> >> Ivan.
> >>
> > ------------------------------**----------------------
> >
> > ______________________________**_________________
> > Flow mailing list
> > Flow at lists.typo3.org
> > http://lists.typo3.org/cgi-**bin/mailman/listinfo/flow<http://lists.typo3.org/cgi-bin/mailman/listinfo/flow>
> >
----------------------------------------------------
More information about the Flow
mailing list