I have an admin module and cannot get the multiselect to pass properly to the observer

        $fieldset->addField('hidden_field', 'hidden', array(
            'name' => 'hidden_field',
            'value' => '1',

      $fieldset->addField('tester', 'multiselect', array(
        'label' => 'label',
        'class' => 'required-entry',
        'required' => true,
        'name' => 'tester',
        'onclick' => "return false;",
        'onchange' => "return false;",
        'value' => '4',
        'values' => array( '-1'=> array( 'label' => 'Please Select..', 'value' => '-1'),'1' => array( 'value'=> array(array('value'=>'2' ,'label' => 'Option2') , array('value'=>'3' ,'label' =>'Option3') ), 'label' => 'Size'  )), 
        'disabled' => false,
        'readonly' => false,
        'after_element_html' => '<small>Comments</small>', 'tabindex' => 1

Now when i save these,

The following is passed ok to the observer

Mage::app()->getRequest()->getParam('hidden_field'); //returns 1

The following multiselect however returns nothing

Mage::app()->getRequest()->getParam('tester'); //returns nothing

if i check the url of the request it looks to me malformed

   [_requestUri:protected] => /index.php/ecms/customer_group/save/key/df52e912e14b962bc721d111729a4e7a?tax_class=3&id=0&hidden_field=1&tester%255B%255D=2&tester%255B%255D=3&tester%255B%255D=4&tester%255B%255D=5&thetitle=mytitle

What part of the process am i getting wrong with this?


1 Answer 1


A multiselect is passed as name=value1&name=value2&name=value3 therefore only value3 is available inside of php (if you don't want to parse the query string)

To change this, you need an array. Change the name to tester[] and it should work.

like this:

$field =$fieldset->addField('store_id', 'multiselect', array(
    'name'      => 'stores[]',
    'label'     => Mage::helper('cms')->__('Store View'),
    'title'     => Mage::helper('cms')->__('Store View'),
    'required'  => true,
    'values'    => Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm(false, true),
  • I have already tried adding [] at the end. not even value 3 is available - the url for some reason is also adding in random characters that mean this parameter is completely malformed.. Thanks for the suggestion though
    – eleven11
    Commented Feb 25, 2014 at 23:49
  • The random characters are encoded [], do you submit the form with ajax? Commented Feb 25, 2014 at 23:49
  • no, it is just a standard form
    – eleven11
    Commented Feb 25, 2014 at 23:54
  • Please check the name in the generated html source. It should be [] and not &whatever; or %255B. If this is not the case something weird happens between clicking the button and the browser sends the request... Commented Feb 26, 2014 at 7:23

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.