Set the element's value equal to the "value" attribute of the option you
want to be selected:
$form = new Zend_Form();
$form->addElement('select', 'cars', array(
'multiOptions' => array('vo' => 'Volvo', 'sa' => 'Saab', 'me' =>
'Mercedes', 'au' => 'Audi')
));
$select = $form->getElement('cars');
$select->setValue('sa');
--
Hector
On Mon, Jun 21, 2010 at 1:22 PM, allergic <
[email protected]> wrote:
>
> Hi I want my Zend_Form drop-down list to preselect an option from my
> database
> like this.
> http://www.w3schools.com/tags/tryit.asp?filename=tryhtml_option_selected
>
> How can this be done with Zend_Form?
>
> I already have this Zend_Form drop-down list code which works with my
> database, but without any preselection.
> http://pastebin.com/kik5kHXE
> --
> View this message in context:
> http://zend-framework-community.634137.n4.nabble.com/Zend-Form-Element-Select-preselected-drop-down-list-problem-tp2263262p2263262.html
> Sent from the Zend Framework mailing list archive at Nabble.com.
>