I added this code for Multi Select
Multi Select in my form
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.