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

Bug #1984 hierselect producing extra characters
Submitted: 2004-07-26 17:51 UTC
From: pear dot 20 dot rytsarsky at spamgourmet dot com Assigned: avb
Status: Closed Package: HTML_QuickForm
PHP Version: 4.3.3 OS: linux
Roadmaps: (Not assigned)    
Subscription  


 [2004-07-26 17:51 UTC] pear dot 20 dot rytsarsky at spamgourmet dot com
Description: ------------ When displaying a form with a hierselect, the characters '//]]>' appear right before the first (main) element. The resulting html has //]]> </script> //]]> </script> right there. I'm guessing that that should just be there once. Reproduce code: --------------- $form = new QuickForm('', 'get'); $sel =& $form->addElement('hierselect', 'category', 'Category: '); $form->addElement('submit', 'submit', 'Search'); $sel->setMainOptions($main); $sel->setSecOptions($sec); echo $form->toHtml(); Expected result: ---------------- Category: [MainSelect] [SecSelect] Actual result: -------------- Category: //]]>[MainSelect] [SecSelect]

Comments

 [2004-07-26 19:31 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!
 [2004-07-27 14:47 UTC] pear dot 20 dot rytsarsky at spamgourmet dot com
Okay... I was able to produce a test case that demonstrates this bug. Here's the code: (mainly from http://www.thelinuxconsultancy.co.uk/quickform.html) ---------- <?php require_once "HTML/QuickForm.php"; $form = new HTML_QuickForm('frmTest', 'get'); $main = array(); $secondary = array(); $main[0] = "England"; $main[1] = "Scotland"; $main[2] = "USA"; $secondary[0][0] = "London"; $secondary[0][1] = "Manchester"; $secondary[0][2] = "Liverpool"; $secondary[1][3] = "Edinburgh"; $secondary[1][4] = "Glasgow"; $secondary[2][5] = "Fort Worth"; $secondary[2][6] = "Boston"; $secondary[2][7] = "Los Angles"; $sel =& $form->addElement('hierselect', 'location', 'Location:'); $sel->setMainOptions($main); $sel->setSecOptions($secondary); $form->addElement('submit', 'btnSubmit', 'Submit'); if ($form->validate()) { // Form is validated, then processes the data $form->freeze(); $form->process('process_data', false); } else { $renderer =& $form->defaultRenderer(); $form->accept($renderer); $form->display(); } function process_data ($values) { echo "<pre>"; var_dump($values); echo "</pre>"; } ?> ---------- Just by adding the two lines: $renderer =& $form->defaultRenderer(); $form->accept($renderer); You can see the behavior described in the initial report.
 [2004-07-27 17:18 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!
 [2004-07-27 17:32 UTC] pear dot 20 dot rytsarsky at spamgourmet dot com
First, I'm not just getting the default renderer, then accepting it... I'm actually changing it between those steps, so they have to stay, but the changes don't have to be there to see the bug. In other words... $renderer =& $form->defaultRenderer(); // do stuff to $renderer here, but that doesn't effect the bug $form->accept($renderer); $form->display(); Also, setting the renderer and calling echo $form->toHtml() as suggested still results in those extra characters. As I understand it, setting the renderer doesn't actually render the form, it just tells the object how to render when toHtml or display is called.
 [2004-07-27 17:49 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!
 [2004-07-28 03:09 UTC] pear dot 20 dot rytsarsky at spamgourmet dot com
My Bad. It's just that that method worked for all elements other than hierselect. I still say this is a bug. I wasn't trying to get tech support, I was simply trying to explain what I did to see the bug. Sorry I misread your code, your solution does seem to work, except that it now requires hidden elements to be added to the form before all the other elements, weird.
 [2004-10-09 19:33 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!