Formbuilder: hierSelect as two predefined elements
| From: | Robert Munteanu | Date: | Sun, 13 Jun 2004 18:53:32 +0000 |
| Subject: | Formbuilder: hierSelect as two predefined elements | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-13123@lists.php.net to get a copy of this message | ||
Hi,
I am trying to customise a form generated by Formbuilder, and I would
like two of the elements to be replaced by a Hierselect element.
The best I could think of is adding this function to the respective
class (with mock values):
function preGenerateForm() {
$select = &
HTML_QuickForm::createElement('hierselect','hs','Membership type',
null,'/');
$mainOpts = array(1=>1, 2=>2);
$secOpts = array( 1 => array(1=>1,2=>2),
2 => array(3=>3, 4=>4)
);
$select->setMainOptions($mainOpts);
$select->setSecOptions($secOpts);
$elems =& $select->getElements();
$main =& $elems[0];
$sec =& $elems[1];
$main->setName('membership_type_id');
$sec->setName('membership_type_detail_id');
$this->preDefElements['membership_type_id'] =& $main;
$this->preDefElements['membership_type_detail_id'] =& $sec;
}
All works out, except the dynamic updating. On closer look, the
javascript code is not created, neither the function, nor for the
elements. But if I pass only the hierselect, it works:
function preGenerateForm() {
$select = &
HTML_QuickForm::createElement('hierselect','hs','Membership type',
null,'/');
$mainOpts = array(1=>1, 2=>2);
$secOpts = array( 1 => array(1=>1,2=>2),
2 => array(3=>3, 4=>4)
);
$select->setMainOptions($mainOpts);
$select->setSecOptions($secOpts);
$this->preDefElements['membership_type_id'] =& $select;
}
I could handle this with preProcess($values), but then at form creation
the original values would not be selected.
Any idea on how I could solve this issue?
Thanks,
--
Robert Munteanu <rombertworf@xnet.ro>