I have a three table in my database, article category and art_cat

article has the id,name,status of the article

category has id,name,status of the category

art_cat has id,art_id and cat_id in the tables.

I have the values inserted respectively, but in my "article form" my category values are not coming selected. I have a multi select dropdown for the category. I have a distinct form for "category". that means my "article form" data goes in article table and "category form" data goes in art_cat table.

$fieldset->addField('category_id', 'multiselect', array(
          'label'     => 'Category',
          'name'      => 'category_id[]',
          'values'   => Mage::helper('blog')->getCategoryOptionValues(true),
          'disabled' => false,
          'index' => 'category_id',

and here is my helper file Data.php

static function getCategoryOptionValues($inlcudeNone = false) {
    $collection = Mage::getModel('blog/blog')->getCollection();
    $values = array();
    if ($inlcudeNone){
        $values[] = array('label' => "--None--", 'value' => 0);
    foreach ($collection as $category) {
        $values[] = array('label' => $category->getName(), 'value' => $category->getId());
    return $values;

How can I get the selected value for the category multi select dropdown. Please somebody help me with this.

1 Answer 1


During the addField call you can specify the option value. For normal field types this takes a string and will set this as the field value, but for multiple select fields you can specify a comma separated string containing each selected value.

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.