Home » HTML » HTML_QuickForm » Bug #5244
after using 'setDefaults' on form loading, select box values are not selected
Details
| Submitted | 2005-08-30 18:39 UTC |
|---|---|
| From | edwinf at xasa dot com |
| Status | Bogus |
| Package | HTML_QuickForm |
| PHP Version | 4.3.8 |
| OS | Irrelevant |
| Roadmaps | (Not assigned) |
Comments
[2005-08-30 18:39 UTC] edwinf at xasa dot com
Description:
------------
When using 'select' elements in a form, after loading the form object with default values, loaded value is not selected automatically. It worked with version 3.2.4pl1 and earlier, but with 3.2.5 it doesn't.
Same problem when select box is a multiple one. It should select selected values.
Test script:
---------------
<?php
$values = array('val_1' => 'Value One',
'val_2' => 'Value Two');
$form =& new HTML_QuickForm('test');
$sel =& $form->addElement('select','loadedValue',
'Select Something');
$sel->load($values);
$form->setDefaults(array('loadedValue' => 'val_2'));
$form->display();
?>
Expected result:
----------------
on HTML display:
<SELECT name='loadedValue' ...>
<OPTION value='val_1'>Value One</OPTION>
<OPTION value='val_2' SELECTED>Value Two</OPTION>
</SELECT>
Actual result:
--------------
On HTML display:
<SELECT name='loadedValue' ...>
<OPTION value='val_1'>Value One</OPTION>
<OPTION value='val_2'>Value Two</OPTION>
</SELECT>