I have a form with three (3) Zend_Form_Element_Select()’s, and I include them all in the addElements call.
Only the last one in the addElements array will show.
Here’s my form code:
class Form_MapBomForm extends Zend_Form {
public function init($option = null) {
parent::init($option);
// instantiate a numbered options list for the SELECT's
$options = array(
NULL => ' - please select - ',
1 => '1 (first)',
2 => '2 (second)',
3 => '3 (third)',
4 => '4 (fourth)',
5 => '5 (fifth)',
6 => '6 (sixth)',
7 => '7 (seventh)'
);
$pn_col = new Zend_Form_Element_Select('pn');
$pn_col->setLabel('PN Column:')
->addMultiOptions($options)
//->setRequired(TRUE)
//->addValidator('NotEmpty')
;
$qty_col = new Zend_Form_Element_Select('pn');
$qty_col->setLabel('Qty Column:')
->addMultiOptions($options)
//->setRequired(TRUE)
//->addValidator('NotEmpty')
;
$first_row = new Zend_Form_Element_Select('pn');
$first_row->setLabel('Start ROW For PN\'s:')
->addMultiOptions($options)
//->setRequired(TRUE)
//->addValidator('NotEmpty')
;
$submit = new Zend_Form_Element_Submit('submit');
$submit->setLabel('Save Mapping');
$this->addElements(array( $pn_col, $qty_col, $first_row, $submit ))
->setName('bommap')
->setMethod('post')
;
}
}
I can switch the order of adding the elements, and regardless, only the last of the three SELECT’s shows with the submit button.
Please help.
~ Mo
You are giving all the select elements the same name ‘pn’. Try giving them different names, e.g.: