I create a custom block, for create slider in front-end. This work perfectly in admin and save in database.
Now I just add, a groupe_id
instance of groupe_customer
.
so lock my form :
$fieldset->addField('target', 'select', array(
'label' => Mage::helper('home')->__("Target"),
'name' => 'sd['.$this->getSlideNumber().'][target]',
'values' => Mage::getModel("home/home_target")->getOptionArray()
));
$groups = Mage::getResourceModel('customer/group_collection')
->toOptionArray();
$fieldset->addField('type_groupe_client', 'multiselect',array(
'label' => Mage::helper('home')->__('Group Customer'),
'title' => Mage::helper('home')->__('Group Customer'),
'name' => 'sd['.$this->getSlideNumber().'][type_groupe_client]',
'values' => $groups,
'required' => true,
));
When i choose multiple group customer,
In my controller saveAction()
, I check value of multi-select look my code :
i do this =>
$slideData['type_groupe_client'] = implode(',',$slideData['type_groupe_client']);
// Slider
foreach ($this->getRequest()->getParam("sd") as $idx => $slideData) {
$slide = Mage::getModel("home/home");
if (isset($slideData["home_id"])) {
$slide->load($slideData["home_id"]);
if(isset($slideData["remove"])){
if(is_file(Mage::getBaseDir('media') . DS . $slide->getImage())){
unlink(Mage::getBaseDir('media') . DS . $slide->getImage());
}
$slide->delete();
continue;
}
} else {
$slide->setCreatedAt(Zend_Date::now()->get(Zend_Date::ISO_8601));
}
$slideData['type_groupe_client'] = implode(',',$slideData['type_groupe_client']);
$slide->addData($slideData);
if (isset($_FILES['sd'.$idx.'_image']['name']) and ( file_exists($_FILES['sd'.$idx.'_image']['tmp_name']))) {
$slide->setImage($this->manageImage('sd'.$idx.'_image'));
} else {
$imageParams = $this->getRequest()->getParam('sd'.$idx.'_image');
if (isset($imageParams['delete']) && $imageParams['delete'] == 1) {
if(is_file(Mage::getBaseDir('media') . DS . $slide->getImage())){
unlink(Mage::getBaseDir('media') . DS . $slide->getImage());
}
$slide->setImage("");
}
}
$slide->save();
}
When I var_dump( $slideData['type_groupe_client'])
, I have so good id in string : string(7) "0,1,2,3"
But they not save in database, just the first when I choose , in this example only 0 is save in my row.
Can you help me please ?
numeric
but instead it should bevarchar