From 3d2e46b14f79602b38291820dc40248da4ad4f4b Mon Sep 17 00:00:00 2001 From: Vincent Augagneur Date: Wed, 26 Jun 2013 11:46:02 +0200 Subject: [PATCH] [-] FO : fixed bug #PSCFV-9388 - newsletter is required error, showing two times --- classes/ObjectModel.php | 8 ++++---- controllers/front/AuthController.php | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 48fe026e4..fc6a40697 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -977,11 +977,11 @@ abstract class ObjectModelCore // Checking for required fields if (isset($data['required']) && $data['required'] && ($value = Tools::getValue($field, $this->{$field})) == false && (string)$value != '0') if (!$this->id || $field != 'passwd') - $errors[] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is required.'); + $errors[$field] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is required.'); // Checking for maximum fields sizes if (isset($data['size']) && ($value = Tools::getValue($field, $this->{$field})) && Tools::strlen($value) > $data['size']) - $errors[] = sprintf( + $errors[$field] = sprintf( Tools::displayError('%1$s is too long. Maximum length: %2$d'), self::displayFieldName($field, get_class($this), $htmlentities), $data['size'] @@ -992,7 +992,7 @@ abstract class ObjectModelCore if (($value = Tools::getValue($field, $this->{$field})) || ($field == 'postcode' && $value == '0')) { if (isset($data['validate']) && !Validate::$data['validate']($value) && (!empty($value) || $data['required'])) - $errors[] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is invalid.'); + $errors[$field] = ''.self::displayFieldName($field, get_class($this), $htmlentities).' '.Tools::displayError('is invalid.'); else { if (isset($data['copy_post']) && !$data['copy_post']) @@ -1136,7 +1136,7 @@ abstract class ObjectModelCore $value = Tools::getValue($field); if (empty($value)) - $errors[] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities)); + $errors[$field] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities)); } return $errors; diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index 7d599ed65..08c96d058 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -414,11 +414,11 @@ class AuthControllerCore extends FrontController if ($error_phone) $this->errors[] = Tools::displayError('You must register at least one phone number.'); - + $this->errors = array_unique(array_merge($this->errors, $customer->validateController())); // Check the requires fields which are settings in the BO - $this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase()); + $this->errors = $this->errors + $customer->validateFieldsRequiredDatabase(); if (!Configuration::get('PS_REGISTRATION_PROCESS_TYPE') && !$this->ajax && !Tools::isSubmit('submitGuestAccount')) {