Hi,
I have an issue in this example:
$f = $this->add('Form');
$f->addField('dropdown', 'mydropdown')
->setEmptyText('Please, select')
->setValueList(array('No', 'Yes))
;
As it can be seen my 'No' value has index 0, and on the page the selected value will be No even if I didn't set a value.
The problem, i think is in the Form_Field_DropDown class in getOption method where the comparison is made with == so 0 and empty string which is the index of the empty text will be both seen as null, two options will have selected attribute and in the dropdown the selected value in this case will be 'No' because it is the last option which has selected.
In my opinion a fix could be:
function getOption($value){
$selected = false;
if($this->value===null){
$selected = $value==='';
} else {
$selected = $value == $this->value;
}
return $this->getTag('option',array(
'value'=>$value,
'selected'=>$selected
));
}