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

Request #4564 Checkboxes can't be created with arbitrary value
Submitted: 2005-06-09 14:52 UTC
From: alands at baraodemaua dot br Assigned: avb
Status: Closed Package: HTML_QuickForm2
PHP Version: 4.3.0 OS: Windows 2000
Roadmaps: 0.1.0    
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 : 32 - 7 = ?

 
 [2005-06-09 14:52 UTC] alands at baraodemaua dot br
Description: ------------ When I create a checkbox field using the HTML_QuickForm::createElement this one comes with attribute value set to 1 and I need to change that value but in the constructor of the checkbox (HTML_QuickForm_checkbox) has a code that update the attribute value only. I think that all attributes need to be updated. Reproduce code: --------------- My code: $res =& $db->query(" select idModule, name from module where status='1' order by name "); while($res->fetchInto($row)) { $formChecks[] = &HTML_QuickForm::createElement('checkbox', 'perm[]', null, $row['name'], array('value'=>$row['idModule'])); } $form->addGroup($formChecks, null, null, "<br>\n"); Code where I think the error is in the constructor of HTML_QuickForm_checkbox: $this->updateAttributes(array('value'=>1)); Code I think that resolv the problem: $this->updateAttributes($attributes); Expected result: ---------------- Checkboxes with defined values. Actual result: -------------- Checkboxes with value attribute equal 1

Comments

 [2005-07-04 17:00 UTC] lionel dot poussin at gmail dot com
I'm also using this class and can confirm that wathever you use (constructor parameter $elementLabel, array('value'=>[myValue]) in constructor parameter $attributes, or setValue function), you always get a checkbox with a value of 1
 [2005-07-27 21:07 UTC] mark at slosarek dot com
Changing the line in the constructor for checkbox from $this->updateAttributes(array('value'=>1)); to if (!isset($attributes['value'])) $this->updateAttributes(array('value'=>1)); allows the value of the checkbox to be set in the attribute field with the the argument 'value'=>'arbitrary value'
 [2006-06-08 13:20 UTC] avb (Alexey Borzov)
Moving feature requests to HTML_QuickForm2.
 [2006-10-20 22:30 UTC] avb (Alexey Borzov)
This behaviour is changed in QuickForm2. Code similar to proposed by "mark at slosarek dot com" was added to checkbox constructor.