Quick_Form - setting default value for a radio group
| From: | Graham Clarke | Date: | Tue, 16 Sep 2003 23:38:14 +0000 |
| Subject: | Quick_Form - setting default value for a radio group | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-7850@lists.php.net to get a copy of this message | ||
Hi - I have a series of radio button groups crated as follows and I'm not able to have the default values be checked.
foreach ( $r['response_set'] as $r_i ) {
$scaled_items[] = & $form->createElement('radio', 'item_'.$r['item_id']. '[response_no]', NULL, NULL, $r_i['response_no']);
}
$form->addGroup($scaled_items, 'scaled_items'.$key, $r['item_id'] . ' - ' . $r['item_text'], NULL, false);
This creates a series of scaled survey questions in a form. For example:
"Did the student demonstrate creative problem solving?" [ ] Not at all [ ] A little bit [ ] Kind of [ ] Most of the time [ ] Always. Each [ ] is a radio button with the only difference between the 5 being the value ( values are integers 1-5 ).So far I've tried adding the attributes array like this
$scaled_items[] = & $form->createElement('radio', 'item_'.$r['item_id']. '[response_no]', NULL, NULL, $r_i['response_no'], array('checked'=>'checked'));
I've also tried using $form->setDefaults($my_defaults); and changing the $appendName parameter to true.
Thanks in advance for any suggestions.
Graham
Graham Clarke
GrahamC@53Tech.com
www.53Tech.com
603.643.9955