[FLOW3-general] arrays in a HTML <form> and Property Mapping
mario chiari
m at mariochiari.net
Wed Oct 31 15:20:57 CET 2012
Christian, All
thanks for your help.
I made some progress.
I succeed to pass an array of objects by a single html form and echo
them back.
Now, I want to do the same for a two models (Father, Son) package such
that a user may enter (Echo, Create, Edit), by a single html form, a
number of fathers and, for each of them, a number of sons.
Indeed, for a fixed number of fathers and sons (say two), I succeed to
get something.
But, I am not sure how to let the user to enter as many items as he wish
(say by providing a simple java script to insert more input fields).
Moreover, I do think my code is somehow 'wrong', and I appreciate any
advise to write it as it should be written.
Please, give a look at http://pastebin.com/YNYaaMT4 and let me know.
Thanks a lot
cheers
mario
On Fri, 2012-10-26 at 08:46 +0200, Christian Müller wrote:
> Hi,
>
> you should start your array in another way, then it will be much easier,
> like so:
>
> newPerson[0][name]
> newPerson[1][name]
yes!
>
> then you have an array of persons that should be mappable. To do that in
> the form you are probably better off to not use the object binding but
> directly assigning names:
>
> <f:form.textfield name="newPerson[0][name]" id="name" /> <<< Btw. your example contains a duplicate id argument which is not allowed in html.
>
yes, i knew.
>
> your echoAction should look roughly like so:
>
> /**
> * @param array<\Test\Basic\Domain\Model\Person> $newPerson
> *
> **/
> public function echoAction(array $newPerson) {
> // do something here, $newPerson should be an array with Person objects inside
> }
>
yes
>
> Cheers,
> Christian
>
>
>
>
> On 25/10/12 21:15, mario chiari wrote:
> > Hello
....
More information about the FLOW3-general
mailing list