[FLOW3-general] Custom Type Converter mandatory for automagical object creation of aggregates?
Ivan Ruiz Gallego
ivan at loglan.net
Fri Sep 23 23:35:54 CEST 2011
Hello,
First of all, I'd like to thank the development team of FLOW3 for all
the work done so far. I have a newbie question
Let's say I have a model \Acme\MyPackage\Domain\Model\Foo with a
OneToMany association to \Acme\MyPackage\Domain\Model\Bar. Foo and Bar
have both a property 'name'. For the property 'bars' within Foo, the
cascade annotation is set. Foo is the aggregate root and has a
repository and an action controller. I have a form to create foos with,
let's say, three associated bars. A template 'new' could look like this:
<f:form action="create" object="{foo}" name="foo">
Foo's name: <f:form.textbox property="name" />
Bar's name: <f:form.textbox property="bars.0.name" />
Bar's name: <f:form.textbox property="bars.1.name" />
Bar's name: <f:form.textbox property="bars.2.name" />
<f:form.submit value="submit" />
</f:form>
I initialize the create action so that the properties 'bar.0', 'bar.1',
'bar.2' can be created. Additionaly, I have a setter method 'setBars'
within the Foo class.
After form submission my foo and my three bars get created and
persisted. But FLOW3 doesn't establish the relation between foo and
bars, i.e. in the db the field 'mypackage_foo' from table
acme_mypackage_domain_model_bar is still NULL.
What am I missing? Do I have to write a Type Converter for Foo, so that
FLOW3 knows how to create the Foo instance from the $_POST['foo'] array?
Or is something in my 'new' Fluid template wrong? Or do I have to
process the POST array on my own, create all objects and set the
relation manually?
Thanks,
Ivan.
More information about the FLOW3-general
mailing list