Skip to main content
edited tags
Link
Muhammad Hasham
  • 8.8k
  • 11
  • 51
  • 105
Tweeted twitter.com/StackMagento/status/1150510440805478402
added 4 characters in body
Source Link

I added this code for Multi SelectMulti Select in my formform.

File Path Should be like: app\code\Vendor\Module\Block\Adminhtml\Mpages\Edit\Tab\Main.php

$fieldset->addField(
            'categories',
            'multiselect',
            [
                'label' => __('Categories'),
                'title' => __('Categories'),
                'name' => 'categories',
                'required' => true,
                'options' => \Vendor\Module\Block\Adminhtml\Mpages\Grid::getValueArray7(),
                'disabled' => $isElementDisabled
            ]
        );

This is my getValueArray7() function in grid file.

static public function getValueArray7()
        {
            $data_array=array();
            foreach(\Vendor\Module\Block\Adminhtml\Mpages\Grid::getOptionArray7() as $k=>$v){
               $data_array[]=array('value'=>$k,'label'=>$v);        
            }
            return($data_array);

        }

It shows me empty multi select field.

I added this code for Multi Select in my form.

File Path Should be like: app\code\Vendor\Module\Block\Adminhtml\Mpages\Edit\Tab\Main.php

$fieldset->addField(
            'categories',
            'multiselect',
            [
                'label' => __('Categories'),
                'title' => __('Categories'),
                'name' => 'categories',
                'required' => true,
                'options' => \Vendor\Module\Block\Adminhtml\Mpages\Grid::getValueArray7(),
                'disabled' => $isElementDisabled
            ]
        );

This is my getValueArray7() function in grid file.

static public function getValueArray7()
        {
            $data_array=array();
            foreach(\Vendor\Module\Block\Adminhtml\Mpages\Grid::getOptionArray7() as $k=>$v){
               $data_array[]=array('value'=>$k,'label'=>$v);        
            }
            return($data_array);

        }

It shows me empty multi select field.

I added this code for Multi Select in my form.

File Path Should be like: app\code\Vendor\Module\Block\Adminhtml\Mpages\Edit\Tab\Main.php

$fieldset->addField(
            'categories',
            'multiselect',
            [
                'label' => __('Categories'),
                'title' => __('Categories'),
                'name' => 'categories',
                'required' => true,
                'options' => \Vendor\Module\Block\Adminhtml\Mpages\Grid::getValueArray7(),
                'disabled' => $isElementDisabled
            ]
        );

This is my getValueArray7() function in grid file.

static public function getValueArray7()
        {
            $data_array=array();
            foreach(\Vendor\Module\Block\Adminhtml\Mpages\Grid::getOptionArray7() as $k=>$v){
               $data_array[]=array('value'=>$k,'label'=>$v);        
            }
            return($data_array);

        }

It shows me empty multi select field.

improved formatting, add more tags to increase the visibility of question
Source Link
Muhammad Hasham
  • 8.8k
  • 11
  • 51
  • 105

I added this code for Multi SelectMulti Select in my formform.

File Path Should be like: app\code\Vendor\Module\Block\Adminhtml\Mpages\Edit\Tab\Main.phpapp\code\Vendor\Module\Block\Adminhtml\Mpages\Edit\Tab\Main.php

$fieldset->addField(
            'categories',
            'multiselect',
            [
                'label' => __('Categories'),
                'title' => __('Categories'),
                'name' => 'categories',
                'required' => true,
                'options' => \Vendor\Module\Block\Adminhtml\Mpages\Grid::getValueArray7(),
                'disabled' => $isElementDisabled
            ]
        );

This is my getValueArray7()getValueArray7() function in grid file.

static public function getValueArray7()
        {
            $data_array=array();
            foreach(\Vendor\Module\Block\Adminhtml\Mpages\Grid::getOptionArray7() as $k=>$v){
               $data_array[]=array('value'=>$k,'label'=>$v);        
            }
            return($data_array);

        }

It shows me empty multi select field.

I added this code for Multi Select in my form.

File Path Should be like: app\code\Vendor\Module\Block\Adminhtml\Mpages\Edit\Tab\Main.php

$fieldset->addField(
            'categories',
            'multiselect',
            [
                'label' => __('Categories'),
                'title' => __('Categories'),
                'name' => 'categories',
                'required' => true,
                'options' => \Vendor\Module\Block\Adminhtml\Mpages\Grid::getValueArray7(),
                'disabled' => $isElementDisabled
            ]
        );

This is my getValueArray7() function in grid file.

static public function getValueArray7()
        {
            $data_array=array();
            foreach(\Vendor\Module\Block\Adminhtml\Mpages\Grid::getOptionArray7() as $k=>$v){
               $data_array[]=array('value'=>$k,'label'=>$v);        
            }
            return($data_array);

        }

It shows me empty multi select field.

I added this code for Multi Select in my form.

File Path Should be like: app\code\Vendor\Module\Block\Adminhtml\Mpages\Edit\Tab\Main.php

$fieldset->addField(
            'categories',
            'multiselect',
            [
                'label' => __('Categories'),
                'title' => __('Categories'),
                'name' => 'categories',
                'required' => true,
                'options' => \Vendor\Module\Block\Adminhtml\Mpages\Grid::getValueArray7(),
                'disabled' => $isElementDisabled
            ]
        );

This is my getValueArray7() function in grid file.

static public function getValueArray7()
        {
            $data_array=array();
            foreach(\Vendor\Module\Block\Adminhtml\Mpages\Grid::getOptionArray7() as $k=>$v){
               $data_array[]=array('value'=>$k,'label'=>$v);        
            }
            return($data_array);

        }

It shows me empty multi select field.

Source Link
Loading