From f9c4e50c191478adcfc7a51e87e1fe10ea222560 Mon Sep 17 00:00:00 2001 From: mDeflotte Date: Wed, 26 Oct 2011 16:04:04 +0000 Subject: [PATCH] [-] BugFix : If a field is empty don't validate this one git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@9658 b9a71923-0436-4b27-9f14-aed3839534dd --- classes/AdminController.php | 2 +- classes/ObjectModel.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/classes/AdminController.php b/classes/AdminController.php index 3f8c770ee..060dc9a63 100644 --- a/classes/AdminController.php +++ b/classes/AdminController.php @@ -1684,7 +1684,7 @@ class AdminControllerCore extends Controller /* Checking for fields validity */ foreach ($rules['validate'] as $field => $function) if (($value = Tools::getValue($field)) !== false && ($field != 'passwd')) - if (!Validate::$function($value)) + if (!Validate::$function($value) && !empty($value)) $this->_errors[] = $this->l('the field'). ' '.call_user_func(array($class_name, 'displayFieldName'), $field, $class_name).' '. $this->l('is invalid'); diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 8ed4d85df..1e26508ad 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -564,7 +564,7 @@ abstract class ObjectModelCore // Hack for postcode required for country which does not have postcodes if ($value = Tools::getValue($field, $this->{$field}) OR ($field == 'postcode' AND $value == '0')) { - if (!Validate::$function($value)) + if (!Validate::$function($value) && (!empty($value) || in_array($field, $this->fieldsRequired))) $errors[] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is invalid.'); else {