I have a multi-sector block of (interests) in my zend form, and I select several parameters from it while I add the user.
Now, when I edit this user, I need to set some default options (which I selected when adding the user).
How can i achieve this? I used populate (Array) in my controller update, but this does not work.
This is the code of the multi-position window in the form of adding / editing a user:
$interests = new Zend_Form_Element_Multiselect('interest'); $days->setLabel('Interests') ->addMultiOptions($user_interests) ->setRequired(true) ->addValidator('NotEmpty');
And when adding the "interest" options in the form of an array of $user_interests :
array(1=>'Blogging', 2=>'Swimming', 3=>'Cricket', 4=>'Yoga')
I selected the first 2 questions when adding the user.
Now when editing, I get user data from the database query. This data array is used to fill out the form, and this array structure is as follows:
Array ( [username] => john [user_dob] => 1981-03-12 [email] => john@gmail.com [interest] => Array ( [0] => 1 [1] => 2 ) )
and, as you can see, the interests of โBlogsโ and โSwimmingโ should be selected in my editing form. But I see that only the "Swimming" option is selected.
source share