From 856c5045f3239be2be8ff71972c28fe8a598457a Mon Sep 17 00:00:00 2001 From: "vishalsingh.qlo325" Date: Sat, 14 Jun 2025 11:30:16 +0530 Subject: [PATCH] Added validation for empty dimension unit --- .../admin/AdminHotelBedTypesController.php | 23 ++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/modules/hotelreservationsystem/controllers/admin/AdminHotelBedTypesController.php b/modules/hotelreservationsystem/controllers/admin/AdminHotelBedTypesController.php index fe90ca442..1b86ff3af 100644 --- a/modules/hotelreservationsystem/controllers/admin/AdminHotelBedTypesController.php +++ b/modules/hotelreservationsystem/controllers/admin/AdminHotelBedTypesController.php @@ -96,7 +96,7 @@ class AdminHotelBedTypesController extends ModuleAdminController public function renderList() { - // added here instead of the constructor since the dimension unit will be update in post processs. + // added here instead of the constructor since the dimension unit will be update afer post processs. $this->fields_list = array( 'id_bed_type' => array( 'title' => $this->l('ID'), @@ -177,6 +177,27 @@ class AdminHotelBedTypesController extends ModuleAdminController return parent::renderForm(); } + public function beforeUpdateOptions() + { + $defaultLangId = Configuration::get('PS_LANG_DEFAULT'); + $objDefaultLanguage = Language::getLanguage((int) $defaultLangId); + $languages = Language::getLanguages(false); + if (!trim(Tools::getValue('WK_DIMENSION_UNIT_'.$defaultLangId)) + && Tools::getValue('WK_DIMENSION_UNIT_'.$defaultLangId) + ) { + $this->errors[] = $this->l('Default dimension unit is required at least in ').$objDefaultLanguage['name']; + } else { + foreach ($languages as $lang) { + if (Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang']) + && (!trim(Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang'])) + || !Validate::isGenericName(Tools::getValue('WK_DIMENSION_UNIT_'.$lang['id_lang']))) + ) { + $this->errors[] = $this->l('Invalid dimension unit in ').$lang['name']; + } + } + } + } + public function processSave() { if (!$this->loadObject(true)) {