Wednesday, January 6, 2010

Form Fields

Ok i make my 10 additional fields with this in my edit form:

<?php $i=0;
while($i<=9)
{
echo $form->input('Additional.'.$i.'.skillset_id', array('label' =>
'Select skill:'));
echo $form->input('Additional.'.$i.'.year_id', array('label' => 'Select
experience range:'));
echo $form->input('Additional.'.$i.'.name', array('label' => 'Skill
name:'));

$i++;
}
?>

So i submit an end up with this array: (debug data before save)

Array
(
[Additional] => Array
(
[0] => Array
(
[skillset_id] => 3
[year_id] => 1
[name] =>
)

[1] => Array
(
[skillset_id] => 1
[year_id] => 3
[name] =>
)
.............. Thru 9 plus [0] = 10
[9] => Array
(
[skillset_id] => 1
[year_id] => 1
[name] =>
)
)

)
There is no add function since the edit form holds the 10 fields only tht
they can work with so fill in 1 or all 10 and that's what you get.

So after clicking save the array above shows what would be saved, below is
what gets pulled from the db I added maually to the db, not thru the form
The data I pull from the db comes back in this format but the fields are
never populated with the user data from the db.

Array
(
[Additional] => Array
(
[0] => Array
(
[id] => 66
[profile_id] => 4b40eea7-2608-4a3b-9c24-7cb04adcd75b
[skillset_id] => 1
[year_id] => 1
[name] => Test 1
[created] =>
[modified] =>
)

[1] => Array
(
[id] => 67
[profile_id] => 4b40eea7-2608-4a3b-9c24-7cb04adcd75b
[skillset_id] => 2
[year_id] => 2
[name] => test 2
[created] =>
[modified] =>
)
)

)

Can someone see where I am going wrong here?

Thanks

Dave

No comments: