I have a form which is used to submit data about multiple people. There are multiple properties for each person, and I'm grouping them like the following:
<input type=hidden name="person1[firstname]" value='Sam'/>
<input type=hidden name="person1[lastname]" value='Higgins'/>
<input type=hidden name="person2[firstname]" value='Jiminy'/>
<input type=hidden name="person2[lastname]" value='Cricket'/>
...etc
When I do the following:
my %hash = params;
die Dumper \%hash;
I get:
VAR1 = {
'person1[firstname]' => 'Sam',
'person1[lastname]' => 'Higgins',
'person2[firstname]' => 'Jiminy',
'person2[lastname]' => 'Cricket',
};
When I was expecting something like:
VAR1 = {
'person1' => { firstname => 'Sam', lastname => 'Higgens' },
'person2' => { firstname => 'Jiminy', lastname => 'Cricket' },
};
Is there a way to get the above, or am I doing it wrong in my HTML?
Edit
I've also tried with empty brackets at the end:
<input type=hidden name="person1[firstname][]" value='Sam'/>
but that just gave:
'person1[firstname][]' => 'Sam',