Removed non required code and added validation in the Gender class

This commit is contained in:
vishalsingh.qlo325
2024-07-02 10:52:51 +05:30
parent ec977a41a0
commit afe671a9eb
2 changed files with 1 additions and 26 deletions

View File

@@ -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),
),
);

View File

@@ -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'])) {