Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 3321270
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T23:02:33+00:00 2026-05-17T23:02:33+00:00

I am creating multiple select element like this and it is showed successfully on

  • 0

I am creating multiple select element like this and it is showed successfully on 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 above element it shows the following html in 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 selected fields and print_r the result like this:

    $request = $this->getRequest();
    $form = new Patient_Form_Patient( $formOptions );

    if ( $request->isPost() ) {
        if ( $form->isValid( $request->getPost() ) ) {
            $values = $form->getValues();
            print_r($values);die();
        }
    } 

It stores only first selected option in array but not all selected elements:

Array
( 
    [clinics] => Array
        (
            [0] => 1
        )

    [save] => Submit
)

Can someone help that how can I submit multiple values ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-17T23:02:34+00:00Added an answer on May 17, 2026 at 11:02 pm

    I have reconstructed your problem and I got no such error. You can see what I did below:

    Application_Form_Patient

    class Application_Form_Patient extends Zend_Form
    {
    
      public function init()
      {
        $this->setName('patient');
    
        $element = new Zend_Form_Element_Multiselect('clinics');
        $element->setLabel("Clinics");
        $element->setAttrib( 'style','width: 240px' );
        $element->setMultiOptions( array('1'=>'clinic1', '2'=>'clinic2' ) );
    
        $submit = $this->createElement('submit', 'submit');
        $submit->setLabel('Submit');
    
        $this->addElements(array(
          $element, $submit
        ));
      }
    
    }
    

    IndexController.php

    class IndexController extends Zend_Controller
    {
    
      function indexAction()
      {
        require_once 'Application/Form/Patient.php';
        $form = new Application_Form_Patient();
    
        $request = $this->getRequest();
    
        if ( $request->isPost() ) {
          if ( $form->isValid( $request->getPost() ) ) {
            $values = $form->getValues();
            Zend_Debug::dump($values);
            die();
          }
        } 
    
        $this->view->form = $form;
      }
    
    }
    

    index.phtml

    <?php
    echo $this->form;
    

    here’s the debug output (one selected item and two selected items)

    # select one item
    array(1) {
      ["clinics"] => array(1) {
        [0] => string(1) "1"
      }
    }
    
    # select two items
    array(1) {
      ["clinics"] => array(2) {
        [0] => string(1) "1"
        [1] => string(1) "2"
      }
    }
    

    Hope it can help you 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I use this library (http://labs.abeautifulsite.net/archived/jquery-multiSelect/demo/) for creating a multiple-select dropdown. I want to update
I'm creating multiple borders to element using box-shadow, but they don't show at Webkit.
I'm creating multiple asynchronous web requests using IObservables and reactive extensions. So this creates
I'm creating multiple form retrieving data from jquery. after that i want to work
I dream of creating a control which works something like this: <asp:SqlDataSource id=dsFoo runat=server
I m creating stored procedure with multiple select statement,as shows below: DELIMITER $$ DROP
so I'm having trouble properly creating this query. Basically, I want to insert multiple
I am creating a form with multiple checkboxes with the same name. I have
I am creating an application where the user can select multiple cells from a
I'm very new to Android. I'm thinking about creating an application that uses multiple

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.