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

Bug #15708 setValue() discuntional
Submitted: 2009-01-21 14:42 UTC
From: cybot Assigned: avb
Status: Closed Package: HTML_QuickForm2 (version 0.2.0)
PHP Version: Irrelevant OS:
Roadmaps: 0.3.0    
Subscription  


 [2009-01-21 14:42 UTC] cybot (Sebastian Mendel)
Description: ------------ ->setValue() does not work Test script: --------------- $form = new HTML_QuickForm2('form'); $defaults = new HTML_QuickForm2_DataSource_Array(array( 'radiotest1' => 1, 'radiotest2' => 2, )); $form->addDataSource($defaults); echo $form->addElement('radio', 'radiotest1')->setValue(1); echo $form->addElement('radio', 'radiotest2', array('value' => 2)); Expected result: ---------------- <input type="radio" value="1" name="radiotest1" id="radiotest1-0" checked="checked" /> <input type="radio" value="2" name="radiotest2" id="radiotest2-0" checked="checked" /> Actual result: -------------- <input type="radio" name="radiotest1" id="radiotest1-0" /> <input type="radio" value="2" name="radiotest2" id="radiotest2-0" checked="checked" />

Comments

 [2009-01-21 19:19 UTC] avb (Alexey Borzov)
Your calls aren't exactly equivalent, setValue() on radios and checkboxes isn't expected to touch "value" attribute, only "checked" one. That's underdocumented, of course, but still the expected behaviour. Changing the first call to ...->setAttribute('value', 1) doesn't quite help, though, and that's a genuine bug. For the record, here is proper testcase for InputCheckableTest, failing with current CVS: public function testBug15708() { $form = new HTML_QuickForm2('bug15708'); $form->addDataSource(new HTML_QuickForm2_DataSource_Array(array( 'aRadio' => 1 ))); $aRadio = $form->appendChild( new HTML_QuickForm2_Element_InputCheckable('aRadio') )->setAttribute('value', 1); $this->assertContains('checked', $aRadio->__toString()); } Will fix that.
 [2009-01-21 21:23 UTC] avb (Alexey Borzov)
This bug has been fixed in CVS. If this was a documentation problem, the fix will appear on pear.php.net by the end of next Sunday (CET). If this was a problem with the pear.php.net website, the change should be live shortly. Otherwise, the fix will appear in the package's next release. Thank you for the report and for helping us make PEAR better.