Re: QuickForm array processing
| From: | Poncho Pilate | Date: | Wed, 17 Aug 2005 06:10:01 +0000 |
| Subject: | Re: QuickForm array processing | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20442@lists.php.net to get a copy of this message | ||
Ok, I'm not having any luck here.
Here is my QuickForm constructor:
$form = new HTML_QuickForm('UpdateForm', 'POST', $_SERVER['PHP_SELF'].'?action='.$action);
Say you have a Date element like so:
$dobOpts = array('language' => 'en',
'format' => 'd M Y',
'minYear' => date('Y'),
'maxYear' => date('Y')-80);
$form->addElement('date', 'dob', 'Date of birth:', $dobOpts);
...and a hierselect element like so:
$sel =& $form->addElement('hierselect', 'location', 'Location:');
$sel->setOptions(array($locations,$regions,$areas));
...with the defaults being set below:
$form->setDefaults(array(
'dob'=>array('d'=>$row['dob_day'],'M'=>$row['dob_month'],'Y'=>$row['dob_year']),
'location'=>array($row['country']-1,$row['region']-1,$row['area']-1),
'email'=>$row['email']
));
Everything is being displayed properly, and the defaults are being set as intended.
At the moment I am trying to access the values as follows:
$form_result = $form->getSubmitValues();
dob day = $form_result['dob'][0];
dob month = $form_result['dob'][1];
dob year = $form_result['dob'][2];
country = $form_result['location'][0];
region = $form_result['location'][1];
area = $form_result['location'][2];
None of this is working...
How would you get the individual values for each day, month, year & country, region and area for DB insertion? (This form is for an administration area, so I'm just going to 'trim' all data before insertion.)
I don't know what wrong with my form, I just followed basic QuickForm syntax, nothing too complex.
Thanks in advance folks.
Mark