Jump to content

Highlighting text boxes in registration form that were not filled correctly (or not at all).


Aaa123

Recommended Posts

Hi all!

 

I would like to change the default errors table that is displayed while creating an account when some of the fields are not filled (e.g. name is required or zip/postal code is invalid).

 

Instead of showing the errors table, I would like to highlight each field that is required but was not filled, or was filled incorrectly (preferably show the text of error near the field).

 

Unfortunately I saw that the errors don't have their keys - they are only generated as text of all of them.

 

I located generation of text errors in AuthController.php and was thinking about changing e.g. this:

$this->errors[] = Tools::displayError('The Zip / Postal code is invalid.');

to this:

$this->errors['zip_code'] = Tools::displayError('The Zip / Postal code is invalid.');

so to be able to refer to the 'zip_code' later.

 

Also I saw that there is a function validateFieldsRequiredDatabase() in ObjectModel.php that is responsible for generating errors when the required field is empty:

if (empty($value))
    $errors[$field] = sprintf(Tools::displayError('The field %s is required.'), self::displayFieldName($field, get_class($this), $htmlentities));

Do you know how to refer to those errors in the later stage?

 

Any help will be much appreciated.

 

Thank you

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...