diff --git a/modules/ant_creationcategories/AdminAntCreationcategories.php b/modules/ant_creationcategories/AdminAntCreationcategories.php index df182a8e..9396aeec 100644 --- a/modules/ant_creationcategories/AdminAntCreationcategories.php +++ b/modules/ant_creationcategories/AdminAntCreationcategories.php @@ -103,6 +103,9 @@ class AdminAntCreationcategories extends AdminTab $groups[] = $row['id_group']; } $id_parent = (int) Tools::getValue('id_parent'); + if(Tools::getValue('category_child')) { + $id_parent = (int) Tools::getValue('category_child'); + } $date = date('Y') . '-' . date('m'); if(Tools::getValue('subcategories2')) { $subcategories = Tools::getValue('subcategories2'); @@ -207,7 +210,7 @@ class AdminAntCreationcategories extends AdminTab ), array( 'type' => 'uploadImage', - 'label' => $this->l('Image Latéral : '), + 'label' => $this->l('Image Latérale : '), 'label-class' => 'col-md-2', 'input-class' => 'col-md-6', 'name' => 'image_category', @@ -354,6 +357,25 @@ class AdminAntCreationcategories extends AdminTab defaultText:\'Nom\' }); + $(\'#id_parent\').trigger("change"); + $(\'#id_parent\').change(function(){ + var id_parent = $(\'#id_parent\').val(); + $.ajax({ + url : \'/modules/ant_creationcategories/ajax.php\', + type : \'POST\', + data : \'id_parent=\'+id_parent, + dataType : \'json\', + success : function(json, statut){ + if (json.errors == false) { + if($(\'#id_parent\').parent().children(".cat-children").length > 0) { + $(\'#id_parent\').parent().children(".cat-children").remove(); + } + $(\'#id_parent\').parent().append(json.data); + } + } + }); + }) + $(\'#form1 .js-switch\').change(function(){ if($(this).is(\':checked\')) { var nb_elements = $(\'#form1 div.tagsinput span.tag\').length; diff --git a/modules/ant_creationcategories/ajax.php b/modules/ant_creationcategories/ajax.php new file mode 100644 index 00000000..19cd1d25 --- /dev/null +++ b/modules/ant_creationcategories/ajax.php @@ -0,0 +1,27 @@ + + + '; + } else { + $data['errors'] = true; + } +} else { + $data['errors'] = true; +} + +$data['data'] = $select; +die(json_encode($data)); \ No newline at end of file