I am trying to populate a select list (Zend_Form_Element_Select) and i have these two arrays i tried. (These are var dumps)
This one works:
array(2) {
[0] => array(2) {
["key"] => int(1)
["value"] => string(4) "Test"
}
[1] => array(2) {
["key"] => int(2)
["value"] => string(5) "Test2"
}
This one doesn’t:
array(3) {
[0] => array(2) {
["key"] => int(1)
["value"] => string(16) "Test Kategorie 1"
}
[1] => array(2) {
["key"] => int(2)
["value"] => string(16) "Test Kategorie 2"
}
[2] => array(2) {
["key"] => int(3)
["value"] => string(4) "rene"
}
}
This is a snippet of my code:
$select = new Zend_Form_Element_Select('video_category', array(
'required' => true,
'label' => 'label_video_category',
//'multioptions' => $this->categories,
'description' => 'text_video_category',
'class' => 'input',
'id' => 'select_video_category'
));
$options = array(
array( 'key' => 1,
'value' => 'Test'),
array( 'key' => 2,
'value' => 'Test2'),
);
Zend_Debug::dump($options);
$select->addMultioptions($this->categories);
$this->addElement($select);
So if anybody has any clue for me, i’d be very thankful, because i’m stuck with this for hours now…
You are using $this->categories in addMultioptions. Just verify if you are assigning the options to this variable.
The following code worked for me for both the arrays:
Arrays used: