From afe671a9ebadbbe1c10bb04d64f099250149b889 Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Tue, 2 Jul 2024 10:52:51 +0530 Subject: [PATCH] Removed non required code and added validation in the Gender class --- classes/Gender.php | 2 +- controllers/admin/AdminGendersController.php | 25 -------------------- 2 files changed, 1 insertion(+), 26 deletions(-) diff --git a/classes/Gender.php b/classes/Gender.php index f3da94ad1..b903bd14f 100644 --- a/classes/Gender.php +++ b/classes/Gender.php @@ -44,7 +44,7 @@ class GenderCore extends ObjectModel 'type' => array('type' => self::TYPE_INT, 'required' => true), /* Lang fields */ - 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isString', 'required' => true, 'size' => 20), + 'name' => array('type' => self::TYPE_STRING, 'lang' => true, 'validate' => 'isGenericName', 'required' => true, 'size' => 20), ), ); diff --git a/controllers/admin/AdminGendersController.php b/controllers/admin/AdminGendersController.php index 74135754b..7331a9c4c 100644 --- a/controllers/admin/AdminGendersController.php +++ b/controllers/admin/AdminGendersController.php @@ -204,31 +204,6 @@ class AdminGendersControllerCore extends AdminController return $this->fields_list['type']['list'][$value]; } - public function postProcess() - { - if (Tools::isSubmit('submitAdd'.$this->table) || Tools::isSubmit('submitAdd'.$this->table.'AndStay')) { - $languages = Language::getLanguages(false); - $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); - $objDefaultLanguage = Language::getLanguage((int) $defaultLangId); - - if ($defaultLangTitle = Tools::getValue('name_'.$defaultLangId)) { - if (!trim($defaultLangTitle)) { - $this->errors[] = $this->l('Social title is required at least in ').$objDefaultLanguage['name']; - } else { - foreach ($languages as $lang) { - if (trim(Tools::getValue('name_'.$lang['id_lang']))) { - if (!Validate::isGenericName(Tools::getValue('name_'.$lang['id_lang']))) { - $this->errors[] = $this->l('Invalid social title in ').$lang['name']; - } - } - } - } - } - } - - parent::postProcess(); - } - protected function postImage($id) { if (isset($this->fieldImageSettings['name']) && isset($this->fieldImageSettings['dir'])) {