Hello I have been searching for it from last couple of hours and have read every matching result google can give me but still can't get it to work.
I am creating a zend form select element through:
this->addElement('select','my_select', array(
'label' => 'Currency', 'value' => 'blue',
'multiOptions' => array( 'red' => 'Rouge', 'blue' => 'Bleu', 'white' => 'Blanc', ), ) );
now I want to populate it through
$form->populate
from the controller, I have tried giving double dimensional array like
$vals = array("my_select" => array("US Dollar", "Pound Sterling"))
and then giving it in:
$form->populate($vals);
but this didnt worked and I am not sure if this will work, at the moment I am building my array like in array( 'red' => 'Rouge', 'blue' => 'Bleu', 'white' => 'Blanc')
the same class as zend form and then passsing it to the addElement multiOptions dynamically, as this guy suggests here:
http://zendguru.wordpress.com/2009/03/06/zend-framework-form-working-with-dropdownselect-list/
that works but I would like to have it through populate and also if someone can suggest me how to select default value as well, I will be very grateful!
Thanks,