[-] BugFix : If a field is empty don't validate this one

This commit is contained in:
mDeflotte committed 2011-10-26 16:04:04 +00:00
1 parent bff241503f
commit 8f2ab56a6c
2 files changed
+2 -2

No files matched your search

+1 -1
View File
@@ -1684,7 +1684,7 @@ class AdminControllerCore extends Controller
/* Checking for fields validity */ /* Checking for fields validity */
foreach ($rules['validate'] as $field => $function) foreach ($rules['validate'] as $field => $function)
if (($value = Tools::getValue($field)) !== false && ($field != 'passwd')) if (($value = Tools::getValue($field)) !== false && ($field != 'passwd'))
if (!Validate::$function($value)) if (!Validate::$function($value) && !empty($value))
$this->_errors[] = $this->l('the field'). $this->_errors[] = $this->l('the field').
' <b>'.call_user_func(array($class_name, 'displayFieldName'), $field, $class_name).'</b> '. ' <b>'.call_user_func(array($class_name, 'displayFieldName'), $field, $class_name).'</b> '.
$this->l('is invalid'); $this->l('is invalid');
+1 -1
View File
@@ -564,7 +564,7 @@ abstract class ObjectModelCore
// Hack for postcode required for country which does not have postcodes // 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 ($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[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.'); $errors[] = '<b>'.self::displayFieldName($field, get_class($this), $htmlentities).'</b> '.Tools::displayError('is invalid.');
else else
{ {