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

Request #16806 allow multiple checkboxes
Submitted: 2009-11-20 00:15 UTC
From: addw Assigned: avb
Status: Closed Package: HTML_QuickForm2 (version 0.3.0)
PHP Version: 5.3.0 OS: any
Roadmaps: (Not assigned)    
Subscription  
Comments Add Comment Add patch


Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know! Just going to say 'Me too!'? Don't clutter the database with that please !
Your email address:
MUST BE VALID
Solve the problem : 19 + 13 = ?

 
 [2009-11-20 00:15 UTC] addw (Alain Williams)
Description: ------------ I should be able to do the following and get back an array: $form->addElement('checkbox', 'vegetable1', array('value' => 1), array('label' => 'carrot')); $form->addElement('checkbox', 'vegetable2', array('value' => 2), array('label' => 'pea')); $form->addElement('checkbox', 'vegetable3', array('value' => 3), array('label' => 'bean')); It might be a good idea to have an option to say that this is what is being requested.

Comments

 [2009-11-23 01:37 UTC] avb (Alexey Borzov)
-Status: Open +Status: Analyzed
Proper code: $form->addElement('checkbox', 'vegetable[]', array('value' => 1), array('label' => 'carrot')); $form->addElement('checkbox', 'vegetable[]', array('value' => 2), array('label' => 'pea')); $form->addElement('checkbox', 'vegetable[]', array('value' => 3), array('label' => 'bean')); Reference: http://news.php.net/php.pear.general/30153
 [2009-11-23 01:58 UTC] mansion (Bertrand Mansion)
-Status: Analyzed +Status: Bogus
PHP doesn't work that way, you should use vegetable[1], vegetable[2], vegetable[3] as element names instead. This can also be done with a group container : $vegetable = $form->addGroup('vegetable' ...); $vegetable->addCheckbox('1' ...); $vegetable->addCheckbox('2' ...); $vegetable->addCheckbox('3' ...);
 [2009-11-23 02:01 UTC] avb (Alexey Borzov)
-Status: Bogus +Status: Analyzed
Bertrand, the original request (as seen on pear-general) dealt with checkboxes named 'box[]', Alain just copied the wrong example to the feature request from email there.
 [2009-11-23 02:12 UTC] avb (Alexey Borzov)
-Status: Analyzed +Status: Closed -Assigned To: +Assigned To: avb
Implemented in SVN.
 [2009-11-23 02:15 UTC] mansion (Bertrand Mansion)
Ah ok I see it now, thanks.