Setting the default option for Zend_Form_Element_Select

Possible duplicate:
Zend Framework - set the "selected" value in the drop-down list box

I have a Zend_Form with a Zend_Form_Select element. I populate it from an array (the code inside Application_Form_MyForm extends the Zend_Form class):

$options = array('first option', 'second option', 'third option');
$this->getElement('mySelect')->addMultiOptions($options);

How can I choose which value will be selected automatically, as in "<option value="second option" selected="selected">second option</option>" ? Thank you!

+3
source share
2 answers

To fill in all form values, you can call $ form-> populate ($ dataAsArray);

, $select- > setValue ('valueHere'); , , sigle, .

: Zend_Form_Element_Multi

+3

Nevermind... ($ form- > populate) . , , , , , - .

0

Source: https://habr.com/ru/post/1759791/


All Articles