Quickform2 addDatasource on select group

From: Date: Wed, 06 Oct 2010 20:28:25 +0000
Subject: Quickform2 addDatasource on select group
Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30751@lists.php.net to get a copy of this message
For some reason when I make a group with a select field in it and want to set the default value for a value from 10-19 it set's it to one, 20-21 sets to two etc. Its as if only the first character get passed trough. (I am using the latest htmlcommon and quickform2) Some example code: require_once 'HTML/QuickForm2.php'; $form = new HTML_QuickForm2('testSelect'); $form->addDatasource(new HTML_QuickForm2_DataSource_Array(array( 'test' => "16" ))); $testSelect = $form->addElement('select', 'test', null, array('options' => $testSelectArray)); echo $form; // This works as expected, the select with value 16 gets selected Now we make a group require_once 'HTML/QuickForm2.php'; $form = new HTML_QuickForm2('testSelect'); $form->addDatasource(new HTML_QuickForm2_DataSource_Array(array( 'testGroup' => "16" // values 1-9 are selected correctly ))); $myTestGroup = $form->addElement('group', 'testGroup')->setLabel('Strange select problem'); $myTestGroup->addElement('select', 'test', null, array('options' => $testSelectArray)); echo $form; OUTPUT: <select name="testGroup[test]" id="test-0"> <option value="0">Select something</option> <option value="1" selected="selected">A</option> <option value="2">B</option> <option value="3">C</option> <option value="4">D</option> <option value="5">E</option> <option value="6">F</option> <option value="17">G</option> <option value="7">H</option> <option value="8">I</option> <option value="9">J</option> <option value="10">K</option> <option value="11">L</option> <option value="12">M</option> <option value="13">N</option> <option value="15">O</option> <option value="16">P</option> </select> Does this happen because I'm an idiot or is this a bug? Best regards, Cedrick

« previous php.pear.general (#30751) next »