Code:
$fieldset->addField('race', 'multiselect', array(
'label' => Mage::helper('tuition')->__('Race'),
'values' => Example_Tuition_Block_Adminhtml_Student_Grid::getValueArray4(),
'name' => 'race',
"class" => "required-entry",
"required" => true,
));
in grid.php
static public function getOptionArray4()
{
$data_array=array();
$data_array[0]='Indian';
$data_array[1]='Chinese';
$data_array[2]='Malay';
$data_array[3]='Eurasian';
$data_array[4]='Others';
return($data_array);
}
static public function getValueArray4()
{
$data_array=array();
foreach(Example_Tuition_Block_Adminhtml_Tutor_Grid::getOptionArray4() as $k=>$v){
$data_array[]=array('value'=>$k,'label'=>$v);
}
return($data_array);
}
and save data like this
$post_data['race'] = implode(',',$post_data['race']); // 0,1,2,3
Now i want to get selected value in admin form how can i do this
Here i want to get selected that value which is saved in database but i m getting only one selected value
asked Jul 30, 2015 at 7:01
ND17
5,2219 gold badges51 silver badges78 bronze badges
-
What values you get in implode(',',$post_data['race']); ?saravanavelu– saravanavelu2015年07月30日 07:57:14 +00:00Commented Jul 30, 2015 at 7:57
-
this value 0,1,2,3ND17– ND172015年07月30日 08:06:25 +00:00Commented Jul 30, 2015 at 8:06
-
you need Indian,Chinese, Malay etc..right?saravanavelu– saravanavelu2015年07月30日 08:49:26 +00:00Commented Jul 30, 2015 at 8:49
-
i want that value selectedND17– ND172015年07月30日 09:02:13 +00:00Commented Jul 30, 2015 at 9:02
-
you want the label or value?saravanavelu– saravanavelu2015年07月30日 09:12:56 +00:00Commented Jul 30, 2015 at 9:12
1 Answer 1
in form.php
Here you can set value
if (Mage::getSingleton("adminhtml/session")->getStudentData())
{
$data = Mage::getSingleton('adminhtml/session')->getStudentData();
$data['race'] = isset($data['race']) ? explode(',', $data['race']) : array(); // using this you can get value of multiple dropdown selected
$form->setValues($data);
Mage::getSingleton("adminhtml/session")->setStudentData(null);
}
elseif(Mage::registry("student_data")) {
$data = Mage::registry('student_data')->getData();
$data['race'] = isset($data['race']) ? explode(',', $data['race']) : array(); // using this you can get value of multiple dropdown selected
$form->setValues($data);
}
answered Jul 31, 2015 at 8:20
ND17
5,2219 gold badges51 silver badges78 bronze badges
default