Problem/Motivation
When the Inline Form Errors core module is enabled, the Commerce Email Registration Login Checkout Pane will result in an error message for the email address field, password field, and the containing fieldset when submitting the form without an email address or with an email address not associated with a user. This is because the $form_state->setError() function is applied to the containing fieldset instead of only the email address field.
This is particularly unsightly because the fieldset error is unstyled since it appears that the Forms API/Inline Form Errors module does not add the appropriate classes to that message for whatever reason.
Proposed resolution
Change the error to use the email address field.
| Comment | File | Size | Author |
|---|---|---|---|
| #6 | Screen Shot 2020-02-18 at 8.15.14 PM.png | 145.06 KB | lkacenja |
| #6 | Screen Shot 2020-02-18 at 8.13.20 PM.png | 155.56 KB | lkacenja |
| #5 | 3113922-commerce-empty-email-address-5.patch | 1.84 KB | daniel korte |
Issue fork email_registration-3113922
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
daniel korteComment #3
lkacenjaDoes this have any impact on sites not using the Inline Form Errors module? When I have a moment, I will test #2 against our installation.
Comment #4
daniel korteNo, it is only with the core Inline Form Errors module installed.
Comment #5
daniel korteCleaned up the code a bit to reuse the existing variable.
Comment #6
lkacenjaI believe I was able to replicate the issue. When I have the Inline Form Errors module installed in combination with the 'email_registration_login' pane I get the following outburst of errors:
This only occurs when I put something in the email filed, but nothing in the password field and attempt to submit. When I fill in a nonsense email and password, I get a much better result:
Patch #5 did not seem to fix the first situation for me. Though I may have applied it incorrectly. I will try to dig deeper when I can.
Comment #7
daniel korteThe second screenshot is how the form should look like / what the patch is intended to fix. I updated the issue title/description because this does apply to an empty email address field and one with an email address that is not in the users table.
@lkacenja I am seeing the fix applied for all situations described above so I am not sure how you got your results? Are you applying the patch via Composer or git?
Comment #8
lkacenjaI see what's happening now. I believe the patch works fine here except for one edge case. If the user is not found via email and proceeds past the empty check at line 114, but $this->config->get('login_with_username') is enabled nothing prevents the parent method validation from firing off. This causes the plethora of errors in my first screenshot above.
I can see a few options here, but I'm not sure what is best.
What do folks think?
Comment #9
thomas.frobieterSame here, furthermore the class "is-invalid-input" is set on the submit button, what doesn't make any sense.
Comment #10
anybodyJust ran into this issue and this is indeed a major problem. Especially that "is-invalid" class is set on the submit button!
We're going to work on it now.
Comment #11
anybody@lkacenja: Re #8 I think maybe we need #2561295: One form validation function should be able to cancel other validation steps here to prevent the upstream validations to fire?
So there are still the issues from #8 and class
is-invalid-inputis set on the input submit, which is wrong.Comment #12
grevil commentedWhat is the status for this in 2.x? Can anybody check?
Comment #13
anybody@Grevil as of #9 ff please check it next weeks. We ran into this in a customer project (DD)
Comment #14
anybodyComment #16
grevil commentedAlright, all fixed now! I agree with @lkacenja in #8, but I don't think this is an extreme edge case as it can occur quite easily, if "login_with_username" is enabled. I fixed the edge case with the second approach of @lkacenja examples in #8:
Basically, if "login_with_username" is enabled, but the username couldn't resolve to an existing user, we also throw the error fixing this edge case quite simple! 😊
Please review!
Comment #17
anybodyChanges LGTM and tests are green! Well done all! :)
Comment #19
anybodyComment #21
anybodyAccidentally merged into 8.x-1.x-dev as the target branch was wrong. Reverted and cherry-picked into 2.x!