-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix: Address lookup validation #98
Conversation
The address lookup validation process was loosing existing form error messages set by other parts of a form. Some of its own error messages also got lost. WIP.
The LocalGov address lookup element should not tamper with error messages raised by other elements. It should also remain inactive when none of its subelements are marked as required.
Marking this pull request as "Draft" to add further improvements. |
The address selection dropdown was not appearing after a form submission error involving the address lookup element. Also: - removed some unused and commented out Javascript code. - improved code comments.
Updated error message text in test code to match updated error handling.
Adding custom error messages to several subelements of the Address lookup element. This is for better UX.
Selecting an address following lookup and then manually altering the selected address skipped validation. Fixed now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Woo that was niche, even to test.
But does as described, and automated tests look good.
@@ -59,6 +59,9 @@ public static function getCompositeElements(array $element) { | |||
$element_list['address_1']['#prefix'] = '<div class="js-address-entry-container">'; | |||
$element_list['postcode']['#suffix'] = '</div>'; | |||
|
|||
// Custom error message for address line 1. | |||
$element_list['address_1']['#required_error'] = t('You must enter an address.'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not blocking this. But might be worth moving to StringTranslationTrait at some point.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. It caused me some unease as well. But eventually stuck to the t() function for consistency with the rest of the file. I have just raised a ticket to replace the entire lot.
Yeah, spotted by @DavidBAsch :D The Address lookup element is a lot better because of him. Thanks for the approval. Merging... |
What does this change?
The LocalGov address lookup element's validation process is losing existing form error messages set by other parts of a form. Some of its own error messages are also getting lost. This change fixes this.
I have also updated the wording for error messages shown on required fields like Address line 1 and Postcode. Instead of saying "Postcode field is required", it now says "You must enter the postcode." Error message wording courtesy of @DavidBAsch
How to test
required
.