Package home | Report new bug | New search | Development Roadmap Status: Open | Feedback | All | Closed Since Version 3.2.16

Bug #6766 hierselect problem with HTML_QuickForm_Controller
Submitted: 2006-02-13 10:45 UTC
From: igor dot grzalja at gmail dot com Assigned: avb
Status: Closed Package: HTML_QuickForm (version 3.2.5)
PHP Version: 4.4.2 OS: Windows XP, Linux
Roadmaps: (Not assigned)    
Subscription  


 [2006-02-13 10:45 UTC] igor dot grzalja at gmail dot com
Description: ------------ Bug occurs if you need multiple select for a second field, and you have specified required rule on hierselect. Test script: --------------- class Page_Account_Credentials extends HTML_QuickForm_Page { function buildForm() { $this->_formBuilt = true; $buttons[0] =& HTML_QuickForm::createElement('button', 'cancel', 'Cancel', array('onclick'=>"javascript:location.href='http://pear.php.net/package/HTML_QuickForm';")); $buttons[1] =& HTML_QuickForm::createElement('submit', $this->getButtonName('next'), 'Next step >>'); $this->addGroup($buttons, 'buttons', '', '&nbsp', false); $services[0] = "Pop"; $services[1] = "Rock"; $services[2] = "Classical"; $subservices[0][0] = "Belle & Sebastian"; $subservices[0][1] = "Elliot Smith"; $subservices[0][2] = "Beck"; $subservices[1][3] = "Noir Desir"; $subservices[1][4] = "Violent Femmes"; $subservices[2][5] = "Wagner"; $subservices[2][6] = "Mozart"; $subservices[2][7] = "Beethoven"; $hireselect =& $this->addElement('hierselect', 'ihierselServices', 'Servisi:', array('style' => 'width: 20em;'), '<br /><br />Usluge:<br />'); $hireselect->setOptions(array($services, $subservices)); $hsElements =& $hireselect->getElements(); $hsElements[0]->setSize(10); $hsElements[0]->setMultiple(false); $hsElements[1]->setSize(10); $hsElements[1]->setMultiple(true); $this->addGroupRule('ihierselServices', 'Choose at least one.', 'required'); $this->setDefaultAction('next'); } } Expected result: ---------------- When you submit the form without choosing any item form second list you get notice that you require to choose some items. Fine. Until now everything works fine. BUT... an error (js object expected) occurs when you try to change selected item form a first select. I think the problem is in HTML_QuickForm_hierselect::setValue($value) since this function does $this->_nbElements = count($value); which is 1 if you did not choose any item form second select. If you change this line to: $this->_nbElements = count($this->_elements); I think this is the bugfix.

Comments

 [2006-05-29 16:12 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!
 [2006-06-18 20:13 UTC] User who submitted this comment has not confirmed identity
If you submitted this note, check your email.If you do not have a message, click here to re-send
MANUAL CONFIRMATION IS NOT POSSIBLE.  Write a message to pear-dev@lists.php.net
to request the confirmation link.  All bugs/comments/patches associated with this

email address will be deleted within 48 hours if the account request is not confirmed!