diff --git a/htdocs/categories/class/categorie.class.php b/htdocs/categories/class/categorie.class.php index 762e0f10f78..3076b9ecacd 100644 --- a/htdocs/categories/class/categorie.class.php +++ b/htdocs/categories/class/categorie.class.php @@ -655,10 +655,10 @@ class Categorie extends CommonObject * Link an object to the category * * @param CommonObject $obj Object to link to category - * @param string $type Type of category ('product', ...) + * @param string $type Type of category ('product', ...). Use '' to take $obj->element. * @return int 1 : OK, -1 : erreur SQL, -2 : id not defined, -3 : Already linked */ - public function add_type($obj, $type) + public function add_type($obj, $type = '') { // phpcs:enable global $user, $langs, $conf; @@ -667,6 +667,8 @@ class Categorie extends CommonObject if ($this->id == -1) return -2; + if (empty($type)) $type = $obj->element; + $this->db->begin(); $sql = "INSERT INTO ".MAIN_DB_PREFIX."categorie_".(empty($this->MAP_CAT_TABLE[$type]) ? $type : $this->MAP_CAT_TABLE[$type]); diff --git a/htdocs/core/class/html.form.class.php b/htdocs/core/class/html.form.class.php index 108fd211865..c7e39077fd3 100644 --- a/htdocs/core/class/html.form.class.php +++ b/htdocs/core/class/html.form.class.php @@ -647,7 +647,7 @@ class Form $disabled = 0; $ret = '