require_once 'HTML/QuickForm.php';
$form = new HTML_QuickForm('example');
$form->setDefaults(array('test' => array('4','15')));
$sel =& $form->addElement('hierselect', 'test', 'Test:', null, '/');
$mainOptions = $db->getAssoc('select pkparent, par_desc from parent');
$result = $db->query("select fk_parent, pkchild, chi_desc from child");
while ($result->fetchInto($row)) {
$secOptions[$row[0]][$row[1]] = $row[2];
}
// Using setMainOptions and setSecOptions is now deprecated
// use setOptions.
$sel->setOptions(array($mainOptions, $secOptions));
$form->display(); |