Salut ,
j'ai fait un module avec 2 helper list pour la configuration ; j'ai mis , pour chacune , un champ status comme suit :
'active' => array( 'title' => $this->trans('Displayed', array(), 'Admin.Global'), 'type' => 'bool', 'active' => 'status', 'class' => 'fixed-width-xs', 'align' => 'center', 'ajax' => true, ),
'activated' => array( 'title' => $this->trans('Displayed', array(), 'Admin.Global'), 'type' => 'bool', 'active' => 'status', 'class' => 'fixed-width-xs', 'align' => 'center', 'ajax' => true, ),
Une deux fonctions pour changer leurs états au niveau base de donnée :
1er fonction pour modifier l'état du champ "activated"
public function changeTestimonialsStatus() { if (!$id_eg_partners_testimonials = (int)Tools::getValue('id_eg_partners_testimonials')) { die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->trans('Failed to update the status', array(), 'Admin.Global')))); } else { $reassurancetestimonials = new TestimonyBloc($id_eg_partners_testimonials); if (Validate::isLoadedObject($reassurancetestimonials)) { $reassurancetestimonials->activated = $reassurancetestimonials->activated == 1 ? 0 : 1; $reassurancetestimonials->save() ? die(Tools::jsonEncode(array('success' => true, 'text' => $this->trans('The status has been updated successfully', array(), 'Admin.Global')))) : die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->trans('Failed to update the status', array(), 'Admin.Global')))); } } }
2ème fonction pour modifier l'état du champ "active" :
public function changeStatus() { if (!$id_eg_partners_infos = (int)Tools::getValue('id_eg_partners_infos')) { die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->trans('Failed to update the status', array(), 'Admin.Global')))); } else { $reassurance = new PartnerBloc($id_eg_partners_infos); if (Validate::isLoadedObject($reassurance)) { $reassurance->active = $reassurance->active == 1 ? 0 : 1; $reassurance->save() ? die(Tools::jsonEncode(array('success' => true, 'text' => $this->trans('The status has been updated successfully', array(), 'Admin.Global')))) : die(Tools::jsonEncode(array('success' => false, 'error' => true, 'text' => $this->trans('Failed to update the status', array(), 'Admin.Global')))); } } }
EN testant une par une , le changement de l'état de fait , le porblème que pour les 2 ensembles , il ne fonctionnent pas comme si un double appel ajax niveau network console se fait