[QuickForm] SetSelected on grouped SELECTs not working?
| From: | Daniel García | Date: | Tue, 11 May 2004 06:04:19 +0000 |
| Subject: | [QuickForm] SetSelected on grouped SELECTs not working? | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-12410@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to set some selected values for SELECTs inputs which reside in a group, but I haven't succeeded. When I perform the setSelected on a non-grouped SELECT input, it's working fine.
A sample:
<?php
require_once "HTML/QuickForm.php";
$select1 = array(1=>"one", 2=>"two");
$select2 = array(3=>"three");
$select3 = array(4=>"four", 5 => "five");
$obj_form = new HTML_QuickForm("form", "POST", $_SERVER['PHP_SELF']);
$obj_select1 =& HTML_QuickForm::createElement('select', 'select1', "Select 1:", $select1);
$obj_select1->setMultiple(true);
$obj_select1->setSize(2);
$obj_select2 =& HTML_QuickForm::createElement('select', 'select2', "Select 2:", $select2);
$obj_select2->setMultiple(true);
$obj_select2->setSize(2);
$obj_group =& $obj_form->addGroup(array($obj_select1, $obj_select2), 'group', "Group:", "");
$obj_select3 =& $obj_form->addElement('select', 'select3', "Select 3 (no group):", $select3);
$obj_select3->setMultiple(true);
$obj_select3->setSize(2);
$obj_select1->setSelected(array(1, 2)); // this belongs to $obj_group $obj_select3->setSelected(array(4, 5)); // this is outside the group$obj_submit =& $obj_form->addElement('submit', 'submit_button', "Submit"); $html = $obj_form->toHTML(); echo $html; ?> TIA -- ===================================== Daniel García http://www.quintopino.com =====================================