Hello,

You can pass 'value' like this:

$form->addElement('select', 'my_first_selector', array(
    'multiOptions' => array(
        'a' => 'Aria Giovanni',
        'b' => 'Bailey Rose',
        'c' => 'Charmane',
    ),
    'value' => 'b'
);

Or call Zend_Form::setValue() like this:

$form->setValue('my_first_selector', 'b');

Or call it directly on element:

$form->getElement('my_first_selector')->setValue('b');

Or populating form like this (1):

$form->setDefaults(array(
    'my_first_selector' => 'b'
));


[1] 
http://framework.zend.com/manual/en/zend.form.forms.html#zend.form.forms.elements.values


2010/6/21 allergic <[email protected]>:
>
> 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.
>



-- 
Sincerely yours,
Aleksey V. Zapparov A.K.A. ixti
FSF Member #7118
Mobile Phone: +34 617 179 344
Homepage: http://www.ixti.ru
JID: [email protected]

*Origin: Happy Hacking!

Reply via email to