[FLOW3-general] arrays in a HTML <form> and Property Mapping
Christian Müller
christian.mueller at typo3.org
Fri Oct 26 08:46:21 CEST 2012
Hi,
you should start your array in another way, then it will be much easier,
like so:
newPerson[0][name]
newPerson[1][name]
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.
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
}
Cheers,
Christian
On 25/10/12 21:15, mario chiari wrote:
> Hello
>
> I need help on the following very simple homework I gave to myself :-)
>
> Consider a usual, simple way to pass an array by a HTML form
> http://www.php.net/manual/en/faq.html.php#faq.html.arrays and say I
> echo back the array of values.
>
> How do I do the same by FLOW?
> I kickstart a one model, one property package:
>
> Package Test.Basic
> Model:
> class Person {
> /**
> * The name
> * @var string
> */
> protected $name;
> ....
> }
> ----
> Now I define a (dummy) newAction() and a New.html fluid template:
>
> PersonController:
> public function newAction() {}
> Template New.html:
> ....
> <f:form action="echo" name="newPerson">
> <f:form.textfield property="name." id="name" /> <<< note the dot (cool!)
> <f:form.textfield property="name." id="name" /> <<< two (or more) input fields
> <f:form.submit value="Echo" />
> ....
> ------
> and Fluid renders:
> <input id="name" name="newPerson[name][]" type="text">.
>
> So far so good.
> Now - speaking very loosely - how do I map the array newPerson to >two<
> Person objects and define a echoAction()?
>
> I am not able to use any of the hints I read at
> http://flow.typo3.org/documentation/guide/partiii/propertymapping.html
> I do not see how to use any TypeConverter (ArrayConverter,
> CollectionConverter, ...)
>
> (I am still using FLOW3 1.1.0-rc1)
>
>
> thanks for your help
> cheers
> mario
>
>
>
>
>
>
>
>
>
>
>
>
>
More information about the FLOW3-general
mailing list