resolved validation issue on customer edit page
This commit is contained in:
@@ -597,13 +597,22 @@ class AdminCustomersControllerCore extends AdminController
|
||||
'title' => $this->l('Save'),
|
||||
);
|
||||
|
||||
$birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
|
||||
if (Tools::isSubmit('submitAddcustomer')) {
|
||||
$this->fields_value = array(
|
||||
'years' => Tools::getValue('years'),
|
||||
'months' => Tools::getValue('months'),
|
||||
'days' => Tools::getValue('days'),
|
||||
);
|
||||
} else {
|
||||
$birthday = explode('-', $this->getFieldValue($obj, 'birthday'));
|
||||
|
||||
$this->fields_value = array(
|
||||
'years' => $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0,
|
||||
'months' => $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0,
|
||||
'days' => $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0,
|
||||
);
|
||||
}
|
||||
|
||||
$this->fields_value = array(
|
||||
'years' => $this->getFieldValue($obj, 'birthday') ? $birthday[0] : 0,
|
||||
'months' => $this->getFieldValue($obj, 'birthday') ? $birthday[1] : 0,
|
||||
'days' => $this->getFieldValue($obj, 'birthday') ? $birthday[2] : 0,
|
||||
);
|
||||
|
||||
// Added values of object Group
|
||||
if (!Validate::isUnsignedId($obj->id)) {
|
||||
@@ -878,7 +887,6 @@ class AdminCustomersControllerCore extends AdminController
|
||||
'referrers' => $referrers,
|
||||
'show_toolbar' => true
|
||||
);
|
||||
|
||||
return parent::renderView();
|
||||
}
|
||||
|
||||
@@ -962,10 +970,28 @@ class AdminCustomersControllerCore extends AdminController
|
||||
$this->errors[] = Tools::displayError('A default customer group must be selected in group box.');
|
||||
}
|
||||
|
||||
// Check the requires fields which are settings in the BO
|
||||
$customer = new Customer();
|
||||
$this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase());
|
||||
|
||||
$days = Tools::getValue('days');
|
||||
$months = Tools::getValue('months');
|
||||
$years = Tools::getValue('years');
|
||||
|
||||
if (!$days
|
||||
&& !$months
|
||||
&& !$years
|
||||
) {
|
||||
$customer = new Customer();
|
||||
$this->errors = array_merge($this->errors, $customer->validateFieldsRequiredDatabase());
|
||||
} else {
|
||||
if (!$days) {
|
||||
$this->errors[] = Tools::displayError("Please select a valid date of birthday");
|
||||
}
|
||||
if (!$months) {
|
||||
$this->errors[] = Tools::displayError("Please select a valid year of birthday");
|
||||
}
|
||||
if (!$years) {
|
||||
$this->errors[] = Tools::displayError("Please select a valid month of birthday");
|
||||
}
|
||||
}
|
||||
|
||||
return parent::processSave();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user