From cb83f436045c5bc974a80f46ba2ebf84c3870763 Mon Sep 17 00:00:00 2001 From: vAugagneur Date: Fri, 21 Sep 2012 08:36:31 +0000 Subject: [PATCH] [-] FO : fixed bug #PSCFV-4137 --- classes/ObjectModel.php | 5 +++++ controllers/front/AuthController.php | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/classes/ObjectModel.php b/classes/ObjectModel.php index 58ccd476d..70feac870 100644 --- a/classes/ObjectModel.php +++ b/classes/ObjectModel.php @@ -911,8 +911,13 @@ abstract class ObjectModelCore public function validateController($htmlentities = true) { $errors = array(); + $required_fields_database = (isset(self::$fieldsRequiredDatabase[get_class($this)])) ? self::$fieldsRequiredDatabase[get_class($this)] : array(); foreach ($this->def['fields'] as $field => $data) { + // Check if field is required by user + if (in_array($field, $required_fields_database)) + $data['required'] = true; + // 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') diff --git a/controllers/front/AuthController.php b/controllers/front/AuthController.php index c6562ffd8..93734140c 100644 --- a/controllers/front/AuthController.php +++ b/controllers/front/AuthController.php @@ -538,7 +538,8 @@ class AuthControllerCore extends FrontController else { $address->id_customer = (int)$customer->id; - if ((Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$address->add()) + $this->errors = array_unique(array_merge($this->errors, $address->validateController())); + if (!count($this->errors) && (Configuration::get('PS_REGISTRATION_PROCESS_TYPE') || $this->ajax || Tools::isSubmit('submitGuestAccount')) && !$address->add()) $this->errors[] = Tools::displayError('An error occurred while creating your address.'); else {