I create several select elements like this and it successfully displays on the form:
$element = new Zend_Form_Element_Multiselect('clinics'); $element->setLabel("Clinics"); $element->setAttrib( 'style','width: 240px' ); $element->setMultiOptions( array( '1'=>'clinic1', '2'=>'clinic2' ) );
After rendering over the element, it displays the following html in the HTML source:
<select name="clinics[]" id="clinics" multiple="multiple" style="width: 240px" size="5" class="required" tabindex="41"> <option value="1" label="clinic1">clinic1</option> <option value="2" label="clinic2">clinic2</option> </select>
But when I submit the form with two fields selected and print_r, the result is as follows:
$request = $this->getRequest(); $form = new Patient_Form_Patient( $formOptions ); if ( $request->isPost() ) { if ( $form->isValid( $request->getPost() ) ) { $values = $form->getValues(); print_r($values);die(); } }
Saves only the first selected parameter in the array, but not all selected elements:
Array ( [clinics] => Array ( [0] => 1 ) [save] => Submit )
Can someone help, how can I send multiple values?
php zend-framework multiple-select zend-form
Awan
source share