I'll give you my code so you have an idea:

so in the form make the field and fill it with all the data:

$GroupsModel = new GroupsModel();
$groups = $GroupsModel->fetchAll();
$selectGroups = array();
foreach($groups as $group) {
  $selectGroups[$group->id] = $group->naam;
}
$group = self::createElement('multiselect', 'fieldname');
$group->setRequired(true)
          ->setMultiOptions($selectGroups)
           ->setLabel('Member off');

in your controller call the members you wanted to be selected:

$UserGroups = new UserGroupsModel();
$groups = $UserGroups->fetchAll('user_id='.$id);
foreach($groups as $group)
{
  $values[] = $group->group_id;
}
$form->fieldname->setValue($values);


aSecondWill wrote:
> 
> Can anyone tell me what i pass to 
> 
>  $form->populate($articleArray);
> 
> to populate a Zend_Form_Element_Multiselect in my form if the element is
> called 'module' ?
> 
> Ive tried adding 
> 
> $modules= array('0' => 4, '1'=>3);
> $articleArray['module'] = $modules;
> 
> but the items with values 4 and 3 don't get selected. any ideas?
> 
> 
> 


-----
visit my website at  http://www.phpscriptor.com/ http://www.phpscriptor.com/ 
-- 
View this message in context: 
http://www.nabble.com/Populate-Zend_Form_Element_Multiselect-tp21557748p21582293.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to