Updated as of #279.
Problem/Motivation
The use of HTML5 required attribute in D8 has resulted in an accessibility regression. Basic client-side validation now occurs *before* hitting the server and running Form API (FAPI) validation functions, so the browser jumps in and displays an error as you attempt to submit the form.
Drupal's validation messages are not displayed, and the browser error is displayed only for the first invalid field.
In addition to the accessibility issue, there have been other general problems reported. See #168 for a summary. Some have been resolved since then. Others may still exist.
Steps to reproduce
- In a browser that supports HTML5 validation:
- Go to
/user/login. - Leave both fields empty and submit the form.
Expected behavior
A Drupal FAPI error message appears for each invalid field.
For manual testing, see also the behavior details in the proposed resolution.
Actual behavior
A browser default HTML5 error message appears instead, and only for the first invalid field.
Proposed resolution
Based on latest conversation.
We will add a setting to settings.php and a warning message to the status report page, as described by the tables below.
When HTML5 validation is disabled, Drupal's server-side validation messages will appear to the user.
Behavior details
| Setting value | HTML5 validation | Status page warning |
|---|---|---|
NULL / missing |
Enabled | The enable_html5_validation setting is not configured in settings.php. In Drupal 12 this setting will default to FALSE, which means HTML5 validation will be disabled on all forms. Make sure your forms will still work the way you expect before upgrading by setting the value to FALSE in a test environment. See the change record for more information. |
FALSE |
Disabled | None |
TRUE |
Enabled | The enable_html5_validation setting will be removed in Drupal 13, and HTML5 validation will be disabled on all forms. Make sure your forms will still work the way you expect before upgrading by setting the value to FALSE in a test environment. See the change record for more information. |
| Setting value | HTML5 validation | Status page warning |
|---|---|---|
NULL / missing |
Disabled | None |
FALSE |
Disabled | None |
TRUE |
Enabled | The enable_html5_validation setting will be removed in Drupal 13, and HTML5 validation will be disabled on all forms. Make sure your forms will still work the way you expect before upgrading by setting the value to FALSE in a test environment. See the change record for more information. |
In Drupal 13, the setting will be removed, and HTML5 validation will always be disabled for all forms.
Remaining tasks
Confirm the approachsmustgrave on 4/2/2026 am taking #263 as agreementDefault to off on 11.xDefault to on on main/12.x- Manual testing
- Change record updates
User interface changes
Depending on the setting value and the Drupal version:
- HTML5 validation is turned off and Drupal's server-side validation messages will appear to the user.
- A warning will appear on the status report page.
See the behavior details in the proposed resolution for more information.
API changes
New configuration in the settings.php enable_html5_validation
Data model changes
NA
Original post
I was very surprised to see that in D8 that we've lost some accessibility in the current release as far as how error messages are presented.
They were much better in D7. In D8 they just say "Please fill out this field.", where in D7 there was a red box describing the problem at the top of the page. The error also had an image and text which identified what exactly the problem was.
Ultimately we need this in core #742344: Allow forms to set custom validation error messages on required fields
But the defaults for D8 should be at least as good as they were in D7.
Previous Proposed resolution
The accessibility team's goal for form validation is #1493324: Inline form errors for accessibility and UX. HTML5 best practices are:
- Javascript validation first
- HTML5 validation for no-Javascript
- Server-side validation
Implementing Javascript validation before the HTML5 validation would restore accessibility for most users. A proposed patch changing the error message to "SomeFormField is required" would improve accessibility for those without Javascript.
| Comment | File | Size | Author |
|---|---|---|---|
| #275 | Screenshot 2026-04-04 at 8.33.07 PM.png | 64.8 KB | smustgrave |
Issue fork drupal-1797438
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 #1
Everett Zufelt commentedI obviously can't assess the severity accurately based on an image. But, if there isn't a description of form errors in one place then this would fail accessibility gate and is a regression from D7 that requires resolution.
Along with correcting the regression we should do root cause analysis of the process to find out how this was able to be committed without adequate accessibility review.
Comment #2
Bojhan commentedSigh, why do we have this regression.
Comment #3
Bojhan commentedLets make the title more meaningful,
Comment #4
xjmI had to read the summary several times before I understood. The screenshots attached are from D8, correct? Can we provide a screenshot of how it is in D7?
I tried a
git log -Sbut I can't find that exact string, and substrings of it don't return any relevant commits. Let's see what it is in D7 so we can search for that?Comment #6
xjmSo @nod_ pointed out in IRC that this is just HTML5 validation, before the form is submitted, and that the implementation depends on the browser. So let's write out the exact steps for testing this, test it in each major browser, and provide screenshots.
The D7 behavior is still there and core is not adding the "Please fill out this field." message -- that's the browser doing that.
Comment #7
nod_that's the HTML5 validation.
This is what happens BEFORE the form is submitted and before Drupal had a change to run the validation functions. This is what happens on an HTML5 browser and we specify the
requiredattribute.Where drupal gets in the way is because of the toolbar, which I pointed out to in #1440628-6: [Meta] javascript toolbar/tableheader with url fragment mess. As usual, js issues don't get much publicity :)
Accessibility is increased, not reduced. It's a matter of not having toolbar in the way and getting users used to HTML5 form error messages. I'll leave critical even if that's not really the case.
Comment #8
xjmOh crossposts.
Comment #9
mgifford@Everett I tried this in both creating a new page & adding a user. Both times the results I got were just the text "Please fill out this field." where before it described the field.
I was also a bit puzzled as to how it was being generated (in my quick review of it), because I couldn't grep for the text or see it easily in the source. It just looks like a tooltip though.
The error message at the top of the page was gone.
Ultimately there is consensus that this is the direction we're needing to go for accessibility:
http://groups.drupal.org/node/212858
http://groups.drupal.org/node/209513
And the current D8 implementation is not going that route at the moment.
Comment #10
mgiffordI've attached the D7 screenshots.
Steps to reproduce is easy. Click on a form with a required field and look for the results. The results are less than they were in D7.
@xjm, I nixed the tags earlier as we were editing at the same time. Added back the manual testing as I think we've got the rest.
Maybe there's a way to enhance the HTML5 output.... Really not sure.
Comment #11
webchickSince this is coming from the browser and not Drupal, there's not much we can do about this except for not using HTML5 required attributes (which seems severely sub-optimal). Before ripping that out, I'd love to know how JAWS et al are handling these errors. If their equivalents are descriptive, this is a non-issue, no?
Comment #12
webchickUh. That's not what I meant to press.
Comment #13
mgiffordBest I could find for ways to improve the client side presentation is:
http://www.deque.com/accessible-client-side-form-validation-html5
http://www.deque.com/accessible-client-side-form-validation-html5-wai-aria
I think we should be able to work with the HTML5 community to find something that works better, but wasn't expecting it to behave this way. Makes sense why I couldn't grep for it though or see it in the DOM.
Better color coding could help. I really can't see getting rid of this client side code though. I can't see removing the
requiredattribute.EDIT: I should have also added the final in this series the one with jQuery:
http://www.deque.com/accessible-client-side-form-validation-html5-wai-ar...
Comment #14
sunTutorial with helpful pointers: http://www.the-art-of-web.com/javascript/validate-password/
WHATWG proposal for Form Constraints: http://www.whatwg.org/specs/web-apps/current-work/multipage/association-...
Based on that, the spec seems to foresee only JS-based customizations to UI messages, since there are various possible states an element might be in.
That said, I don't quite get why the spec doesn't simply allow for a custom error message through the attribute value; i.e.,
Comment #15
Everett Zufelt commentedSo html5 browsers add something which is exposed by D8 using html5 attributes, what (if anything) is taken away from the D7 experience when using D8 and an html5 browser? If nothing then this is neither a regression nor critical.
Comment #16
webchickThe deal is that because in Drupal 8 we're now using the HTML5 required attribute to do basic client-side validation *before* hitting the server and running FAPI validation functions, the browser jumps in and provides an error as you attempt to submit the form.
In Drupal 7 we did a lot of work to make the FAPI error messages accessible, including a) an icon + alt tag to indicate their relative importance (e.g. warning/notice), b) an error message which included the name of the field for reference, c) a red outline on the field.
But in D8, those nice error messages are never displayed, in favour of the default browser response to a required field which in Chrome's case it looks like is "Please fill out this field" which includes none of the enhancements to error messages in D7, thus an accessibility regression.
Comment #17
webchickBut this is why I'd love to see testing in an actual screenreader, which may not even support this attribute, or if it does it might be smart enough to make the error messages sane. I don't see where this was done.
Comment #18
ParisLiakos commentedSeriously, i dont think we should stop new features getting in d8 because of this, which actually is a problem because people havent get used to html5 yet..
sorry for removing regression tag
Comment #19
Everett Zufelt commentedPreliminary testing:
JAWS 13 + FF 15
When submitting the form JAWS speaks "Alert: Please fill out this field." Even if there are multiple fields the same message is read.
VoiceOver + Safari on Lion reads nothing at all.
This is both critical (users cannot determine the error message), and a regression.
Comment #20
dave reidWhy is this a Drupal issue and not a browser implementation issue?
Comment #21
nod_+1 I'm pretty sad that we'd need to remove all HTML5 form improvement (which are quite significant for mobile users) because of poor implementation of HTML5 from browsers/screen readers.
Comment #22
cweagansIMO, this is a browser implementation issue, and is therefore not a critical bug for Drupal. I can, however, see it as a major bug that depends on browser vendors to fix their crap.
Comment #23
quicksketchYou can set your own error handling for elements using the "required" HTML5 attribute. Apparently the "title" attribute will be used as the validation message (which doesn't make sense to me), but the better solution would be to have Drupal implement oninvalid for all form elements and provide a smoother handling of errors (perhaps mimicking the non-JS approach by adding a message at the top of the page).
Comment #24
quicksketchComment #25
Everett Zufelt commentedI'm not saying that @required necessarily needs to be removed. I am saying that this is a regression in accessibility (we can't assess the product outside of the context of the environments within which it will be used). In my opinion this is a critical regression. Users will, in some cases, not know why their form is not submitting.
Nevertheless, I won't change the priority back to Critical again. This issue * must * be resolved for D8 to ship, whatever status ensures that is fine with me.
@nod_
Why do you claim all form improvements? The only thing being talked about here is @required.
@Dave Reid
"Why is this a Drupal issue and not a browser implementation issue?"
It is both. We are implementing part of html5, which when used in browsers that support it significantly degrade the user experience (accessibility). While I believe that browsers need to implement this better, we can remove the accessibility barrier by attempting to mitigate the barrier prior to the browser. What does that look like? I don't know, let's try to brainstorm solutions. Ideally @required won't be removed, perhaps it will need to be.
Edit: In the past 2 days I was using forms on non-drupal web applications and could not figure out how to get the forms to submit. Not at all related to @required, but let me tell you, as an end user, those systems were critically broken as they "render[ed] a system unusable ".
Comment #26
Everett Zufelt commentedAs far as a regression goes, adding @required did change the expected behavior, FAPI errors no longer show when a field is required and has no value. This regression may indeed meet user needs better than the former behavior, but as for now the product no longer performs as formerly expected.
Comment #27
nod_If you input a wrongly formatted email in a html5 email input type, you'll get an error alike the required one and if you're using the pattern attribute, same thing. It's not just the required attribute we're talking about here even if it's the most visible one in core at the moment.
Comment #28
ParisLiakos commentedIt is not only the required attribute that browsers implement validation.
It is also, number, email and url fields like the screenshots below
Comment #29
fabianx commentedI would suggest to validate the form via JS before actually submitting.
The rules for the HTML5 attributes are rather clear and error messages could easily be provided as part of the form (or - if needed also by calling an AJAX function to get a meaningful error message.)
Comment #30
Everett Zufelt commentedTesting again with JAWS and FF the following is spoken when an invalid value is set and I attempt to submit the form.
type="url"
"Please enter a URL"
type="email"
"Please enter an e-mail address"
When required="required" is also set for a field "Alert: Please fill out this field" is read on an attempted submit, not the validation message. Only one message is read on submit, regardless the number of validation errors.
Again, VoiceOver + Safari on Lion says nothing at all.
Comment #31
nod_The fact that only one error message is read makes sense to me, the validation is field by field and since having an invalid field prevents the form form being submitted, it alerts the first error and don't move on until it's fixed. Browsers seems to focus the field that needs some attention, makind the error message very much contextual. Once the first issue is fixed, the next error will show up if there are still any.
Using setCustomValidity imply that JS is available, so I'm not sure we can rely on it for this.
Comment #32
quicksketchI would expect that we'd be willing to accept the default browser behavior as "degraded functionality" in the event that JavaScript was not available. There's nothing terribly wrong with the built-in browser validation, it's just not as clear as the Drupal 7 (non-HTML5) implementation without JS. In any case, as time goes on and HTML5 becomes more common, the problems with screenreaders and new browsers will be resolved by that software.
I think the best thing to do is use a combination of title attributes (which get used in the event of errors) and setCustomValidity. Using HTML5 validation is still useful, especially with things like type="email" input fields. Unless we decide to add the "novalidate" property to all forms in Drupal (which I think would be a huge mistake), setting custom validation via JS is our only option.
Comment #33
nod_That sounds pretty good to me. So should we close this one and bump #52051: Validation API/UI to critical then?
Comment #34
Everett Zufelt commentedI'd agree that JS validation, rather a JS validation API with defaults for Core fields, is the way to go. For those UAs where JS isn't available the experience will be degraded, as it is in many other places on Drupal sites.
Comment #35
sunUgh. The actual situation is actually much worse than what we've discussed here so far.
The new
requiredattribute disallows me from canceling my own account.Screenshot:
Clicking "Cancel account" triggers the browser's validation for required input fields in the form. The e-mail address happens to be empty in this form due to a unrelated core bug. That's irrelevant though; it's just one of many possible cases in which an alternate/secondary form action is not executable.
What matters is that the HTML5 'required' attribute breaks the entire purpose of
#limit_validation_errors, since the form is validated ahead of time on the client-side already.I'm afraid, this turns more and more into a critical regression compared to D7, and we have to find a solid answer for this problem in D8/HTML5, so bumping priority to critical.
Possible answers are manyfold; e.g.:
Comment #36
ParisLiakos commentedWould be more than required.
eg in your same example if the email field is an HTML5 email field it would fail validation for email so you could not submit the form. So that would be more of, stop using HTML5 form attributes all together, not just
requiredattribute.IMO, submit actions that are unrelated with the form content should be turned into links.
But best solution ofc would be implementing JS libraries that mimic client side FAPI validation, which is not easy i guess
Comment #37
Everett Zufelt commented@rootatwc
I believe the email field only validates if there is a value in the field. A null string does not fail validation as an e-mail address, but would fail validation if required="required".
See also html5 bug at https://www.w3.org/Bugs/Public/show_bug.cgi?id=15229
Comment #38
ParisLiakos commentedAh, thanks, that makes sense i think.
But then again, imagine if i started typing my email, but then say, well forget i ll just delete my account.The validation fails because i left my mail unfinished. Pretty bad example, but the behavior is different from d7.
My point here is that browser validation, acts on several attributes with HTML5 and if we want to have the same behavior on forms for Drupal8 just like we had in D7, we either remove all HTML5 form support or write a JS library that does this.
Comment #39
nod_What's described in #35 would fail without HTML5 validation. The validation is run by Drupal and on cancel account displays a
E-mail address field is required.message. #35 is not a regression, it just fails earlier as described previously in the issue.Comment #40
mgifford@sun I think that is a bigger bug than this issue. The behavior of required fields (even in nodes) seems to be (in D7 as well) that you have to meet the requirements before you delete the content.
I did something similar with nodes in that I created a node with no Body content. I then edited the Content Type to change it so that Body was required. I then saved that and went to try to delete the node I'd just created. I couldn't delete the node before I had met the requirements that were now in place to save the node. It was further annoying that I had more than one requirement to meet, so simply having something in the body wasn't sufficient.
I do think this is an important issue to nail down in D8, but it should be a new issue rather than this one here.
I'm also for implementing some "fancy client-side JS library to re-enable #limit_validation_errors" rather than removing the HTML5 'required' attribute. But ya, that's more work. I'm really surprised that there aren't more examples out there, but I'll keep looking.
Comment #41
ParisLiakos commentedhmm nod_ is right, i remember having this annoyance when trying to delete nodes with missing required fields.
I thought, hey i am trying to delete this why you want me to fill this in?
So this is the same behavior in D7..
But i think the problem remains with #limit_validation_errors
Comment #42
mgiffordCouple other possible solutions:
http://www.deque.com/accessible-client-side-form-validation-html5-wai-ar...
http://www.nomensa.com/blog/2010/accessible-forms-using-the-jquery-valid...
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
use of aria-required="true":
http://john.foliot.ca/required-inputs/
http://www.alistapart.com/articles/aria-and-progressive-enhancement/
Having real time validation would in many ways replace the need to have the summary of the top on submit. I'm not happy with any of the solutions I've seen though.
EDIT: Best practice suggested by Twitter's @pjackson28:
Comment #43
nod_The jQuery validation is a nightmare to work with. I had to do some not quite simple things and didn't enjoy it one bit.
With the button type patch on the way #1238484: Ability to mark the form buttons to be of a specific type (so that they can be styled differently), it'd possible to add some JS to specific buttons that adds a
novalidateattribute to the form when clicking on a cancel or preview button. This will ignore any HTML5 validation thing. Drupal validation will still kick in but that's not the topic of this issue.Comment #44
mgiffordCheck out https://github.com/fnagel/jQuery-Accessible-RIA
Particularly his demo here:
http://fnagel.github.com/jQuery-Accessible-RIA/Formular/http://fnagel.github.io/jQuery-Accessible-RIA/Form/
I agree that it's a real pain to deal with.
EDIT: Adding another example -
http://wet-boew.github.com/wet-boew/demos/formvalid/formvalid-eng.htmlhttp://wet-boew.github.io/wet-boew/demos/formvalid/formvalid-en.html
These links are out of date.
Comment #45
catchI think we should roll back the native required usage then have an issue to put it back in again.
This looks like a hard one to fix and an easy roll-back (http://drupal.org/node/1174938#comment-5698572).
Comment #46
nod_I'd be really sad to see it go.
Most if not all of the issues raised here came from people not getting the flow of validation or forgetting that core behaves the same way. For example the "add more" button with JS disabled still works when I create a node with an empty title, and the "Save" button still triggers the form validation and prevent form submission like it's supposed to. So I'm not sure I ran into a case where
#limit_validation_errorsis actually ignored in core.The only real difference that I've seen is that HTML5 validation stops on the first error it encounters, which make total sense.
Working around it in specific cases with
novalidateon the form element or withformnovalidateon the submit button itself (so that "Save" triggers HTML5 validation but not "Preview" for example) is entierly possible.Can people please read the spec before rolling this back? Thanks.
(edit) actually, formnovalidate was introduced in #1174938: Natively support the HTML5 required and aria-required FAPI properties. That's why add more works.
Comment #47
attiks commentedSince I've created clientside_validation I've some experience with client-side validation, so my 2c
HTML 5 build in validation works but:
So for clientside_validation we decided to disable the HTML 5 validation and add our own validation so it behaves the same as what Drupal does after a postback (user can still enable HTML 5 validation), clientside_validation uses jquery.validate.js so if there're problems (#43) please share.
I'v had a couple of talks on how to solve this for Drupal 8, but the major problem is that there's no uniform validation system in Drupal core. If we want this to be solved, we first need to handle the validation on the server side (#52051: Validation API/UI). The biggest problem we're facing now with clientside_validation is that we need to integrate all contrib modules separately.
Comment #48
webchickI agree that rolling back is looking preferable at this point to a critical bug that's been sitting here unresolved for almost a month, much as I hate to say it. :\ If there's not been some movement around a client-side validation replacement / introduction of formnovalidate in more places by this time next week, I think that's what we should do for now.
Comment #49
tim.plunkettI believe this is the proper patch to roll this back. The original commit was pre-PSR-0.
Comment #50
nod_I disagree but if we can reasset the situation closer to release to see how browsers+screenreader handled the problem and put that back in if the situation is good enough, sure, why not, roll it back.
Comment #51
nod_A counter-patch to support my position. It's not pretty, it won't scale well to other things beside #required but it works. At least now the error message will say which field is required in the error message. It supports the #required_error custom message as well.
It doesn't solves the browsers and screenreaders issues but it's a start.
Comment #53
damien tournoud commentedSo, it seems like we add
novalidateto every button that uses#limit_validation_errors, so this part of the issue is bogus?Comment #54
nod_indeed.
The issue left is the accessibility of HTML5 validation. I don't think we should aim at replicating all FAPI messages with HTML5 validation. Using only basic validation should be good enough for now. The issue was that error message didn't have any context when several fields are required. My previous patch uses FAPI required message to replace the default "This field is required" with "SomeFieldTitle is required.".
Comment #55
damien tournoud commentedBecause there is only limited loss in functionality, and because this is essentially a browser bug, I'm downgrading this to major.
Comment #56
mgiffordIt's important to keep in mind the goal that the accessibility team has been working for is #1493324: Inline form errors for accessibility and UX
Best practice of form validation with HTML5 is really here:
https://github.com/wet-boew/wet-boew/wiki/Form-validation
Which follows:
Comment #57
attiks commented#56 what you describe is the same is what clientside_validation is doing, even using the same jquery validation library, but without the need to use class names to specify validation rules.
FYI: #1696648: [META] Untie content entity validation from form validation is adding the concept of constraints to Drupal 8 and once finished will make it easy to 'convert' the PHP validation to javascript.
Comment #58
mgiffordLooks like the patch mentioned in #57 is making some progress. Tagging for sprint.
Comment #59
mgiffordLooks like the patch mentioned in #57 is making some progress. Tagging for sprint.
Comment #60
mgiffordLooks like the patch mentioned in #57 is making some progress. Tagging for sprint.
Comment #61
mgiffordLots of js code to borrow from here:
http://bassistance.de/jquery-plugins/jquery-plugin-validation/
https://github.com/wet-boew/wet-boew/blob/master/src/js/dependencies/val...
https://github.com/wet-boew/wet-boew/blob/master/src/js/workers/formvali...
https://github.com/wet-boew/wet-boew/blob/master/src/js/dependencies/val...
Comment #62
mgifford#51: core-custom_required_message-1797438-51.patch queued for re-testing.
Comment #64
dcam commentedhttp://drupal.org/node/1427826 contains instructions for updating the issue summary with the summary template.
The summary may need to be updated with information from comments.
Comment #65
star-szrIssue summary was written by @BrightBold. Thanks!
Comment #66
mgifford#51: core-custom_required_message-1797438-51.patch queued for re-testing.
Comment #68
mgiffordIt seems a bit primitive in some ways, but can't we just remove the HTML5 attributes by default in core/misc/form.js using something like:
$('input').removeAttr('required');We might want to be a bit more specific about when we're removing them as it may be that the native HTML5 validation is better in some browsers, but we haven't seen a lot of progress on the issue.
This would be a good use of progressive enhancement, as if a user is browsing a page without Javascript then they would still be able to take advantage of the validation messages.
EDIT: Also useful reference - http://toddmotto.com/progressively-enhancing-html5-forms-creating-a-requ...
Comment #69
jessebeach commentedI added this issue and patch to make the status message area discoverable through assistive user agent landmark topologies: #2047175: Make the status message field discoverable by assistive technology agents; alert AT agent users to error messages
Comment #69.0
jessebeach commentedCreated an issue summary to update with the latest comments in the issue. Not perfect but at least better.
Comment #70
mgiffordComment #71
mgiffordReally we need a JS person to take this on...
Comment #72
cosmicdreams commentedWe're looking at this issue at TCDrupal 2014
Comment #73
cosmicdreams commentedpatch needs to be remade.
Comment #74
cosmicdreams commentedRedid the patch
Comment #75
tim.plunkettComment #76
mgifford@cosmicdreams' patch in #74 was just part of a demo for TCDrupal 2014.
Comment #77
mgiffordComment #78
BarisW commentedI really like Mike's reference to http://toddmotto.com/progressively-enhancing-html5-forms-creating-a-requ... (demo).
Would this work? The only real change is that we need to add the form-errors to the HTML by default in a hidden div.
Comment #79
nod_The problem I have with that is that it's a solution only for the required HTML5 stuff. Not the format or type validation which will still use browser validation.
So either we have a formnovalidate on all submit buttons or we leave it like now. I don't want to go down the clientside validation road maintaining 2 sets of validation function in PHP and JS.
Comment #80
rootworkFYI I'm still running into this in 8.0.0-beta9, and it is really confusing UX. On a content type with multiple fields, I'm seeing site editors scroll to the bottom to hit publish, and then get that generic error message ("Please fill out this field.") that doesn't help them know what to do.
I think this is going to be a serious usability issue for non-technical users. I also like Mike's suggestion that Baris mentioned in #78. Perhaps it doesn't address all the HTML5 stuff, but it addresses a big UX regression. And if there are other solutions, let's brainstorm them.
Comment #81
fabianx commentedIn the end a accessibility or Usability core gate maintainer could make this issue critical (with needs triage by core committers of course).
It falls under the new directions for a core gate maintainer needing a revert or workaround to ensure his or her subsystem is releasable.
So it is up to whoever maintains UX / AX to decide if this should be release blocking or not. (being a regression too)
If it is, please make it Critical ASAP, so that our stats are correct. Thanks!
Comment #82
attiks commentedAs said in #47
So the best approach is probably to add formnovalidate to all submit buttons like @nod_ said in #79, it can either be added on the PHP side or the js side.
Outputting all errors messages as proposed in #78 might work, but will only work with javascript. And it will also output a lot of HTML which is only needed once in a while.
Comment #83
mgiffordI'm not a JS guy, but have been trying to do some more research on this to look at other options.
The Government of Canada is leveraging the jQuery Validation project, they have some documentation on Github.
The WET Toolkit uses a generic form validation script:
https://github.com/wet-boew/wet-boew/blob/master/src/plugins/formvalid/f...
I do need to get more information though to see how this could be applied to Drupal.
Edit: List of examples is here
Comment #84
Bojhan commentedI don't like it but is there any way around it? I don't think our own solution here will have long-term viability?
Comment #85
mgiffordIn #1493324: Inline form errors for accessibility and UX this approach was mentioned:
http://developer.telerik.com/featured/building-html5-form-validation-bub...
I haven't looked at it much more than this warning:
Still it would be an interesting model to look at for D8.
Comment #86
rootworkRight, I saw that warning too, but it seems to me that we have indeed built those things. Constructing consistent error messages across a web application/framework like a CMS seems like exactly the kind of justifiable use case for this kind of thing.
Comment #87
mgiffordyes, if we can do it in an accessible format we're golden.
Then the HTML5 required elements are just a fall-back for when there is no JS.
Comment #88
crasx commentedI think the patch from comment 51 is a good place to start. Even if we add inline errors we may want to update the html5 messages.
The problem is I'm not sure what the best approach is. It appears as though we would need to include a javascript file every time there is a required field to handle this logic. If this is true then can anyone suggest the best place to add this include? I'm new to the d8 render pipeline, but I imagine it would be in the same place where the required "*" is added to the label.
The second thing we need to consider is what the messaging would look like. Do we want to keep the same behavior as #1493324: Inline form errors for accessibility and UX where it adds a global message and highlights around the field with an error? If so then an easier option is to force ajax validation on all forms, though I'd be willing to bet it will cause a lot of headaches after and may not work well.
Comment #89
mgiffordI think it would be best to be consistent with the inline form errors that are presently in Core. We don't want to add another UI element if we can avoid it.
EDIT: Looks like system_library_info() functionality has been moved into a YAML file.
Comment #90
Bojhan commentedComment #91
rootworkI'm guessing this is 8.1.x now?
Comment #92
mgiffordUnfortunately.... But I think so.
Comment #93
xjmComment #95
mgiffordThe patch to build on for this issue is from #51 @nod_ from October 20, 2012. That was a long while ago now, but obviously it needs more than just a re-roll at this stage.
@crasx in #88 has good points about how to solve this problem & what the behavior should be.
Comment #96
mgiffordComment #98
dmsmidtI think this may be one of the most important issues with the current D8 usability. For disabled and non disabled users alike. A CMS is all about forms, so should have top priority. We see a trend towards decoupled Drupal, which even makes the data input part of the software even a bigger part of it's core business.
Let's summarize this issue and add some extra points. There has been some great feedback.
HTML5 browser error messages as is in D8, have too many concerns, which mostly are not to be fixed in Drupal without adding a JS layer or removing them alltogether. They may be improved by browser vendors in the future, but still, will most likely not be perfect.
Concerns:
- Loss of uniform and exhaustive error representation. Because first of all, some elements have HTML5 validation and some don't. Secondly, in some cases a user can resolve the HTML5 message and after submitting still get a server side generated error because the validation rules are different on the client and serverside. Often the HTML5 version just doesn't show the real problem. Also the styling of these errors are vastly different. This all makes using Drupal more confusing and irritable.
- On common browsers they are often not really notable/obvious in terms of contrast/design. This factor partly depends on the Drupal theme used.
- The error language doesn't use the site language, but the browser language.
- Screen readers (JAWS and FF) read unhelpful messages (no context) out loud.
- There is no overview of all errors, I think this hasn't top priority since for most users the generated error is in view.
I agree with @nod_ that we should prevent duplication of the validation logic on the client side.
So let's go ahead with the proposed general solution.
1. Use JS to throw our own error messages. We should reuse the Inline Form Errors style, because then styling and placement is already done for all forms.
Because ideally we want consistency between server and client side errors I'm thinking about Ajax validation per field directly after it loses focus, and remove HTML5 form validation completely with JS. We should see if this is fast enough for a good experience. However, as a starter I would say let's start with generic 'required' messages. On the other side if we can just rerender the form element server side with the error we don't have to manipulate the DOM too much with JS.
We should look at the latest developments of
https://www.drupal.org/project/clientside_validation.
2. If there is no JavaScript, we use the HTML 5 standard browser validation as fallback, but with usage of the element title (patch #51 needs work).
3. And lastly, we fall back to plain serverside validation only, which is currently the most accessible version ironically enough.
Did I miss something? What are your current thoughts about 1?
Let's get 2. in core a.s.a.p, for at least it provides some improvement.
Comment #99
vprocessor commentedComment #100
vprocessor commentedrerolled
Comment #102
skaught@vprocessor seems like that is a very large patch. possibly your branch wasn't up-to-date?
Comment #103
vprocessor commented@SKAUGHT, I used #51
Comment #105
idebr commentedIt turns out the html5 validation introduces a much larger usability issue that I have not yet seen mentioned in this issue.
When a required field is not currently visible, for example because it is grouped in a vertical tab, the browser (Google Chrome) does not focus the element but also will not trigger a form submit. The only feedback that is displayed comes through the developer console. This results in a very confusing state for users.
I have attached a screen capture below of this behavior:
Comment #106
idebr commentedSince javascript client side validation would need to be compatible with the use case in #106 where field are not currently visible, this would mean a significant amount of work. As a short time solution I have opted for the solution by tim.plunkett in #49 to remove the html5 required attribute altogether while we work on a proper client side implementation for input validation.
I left in the 'formnovalidate' html5 attribute in, since other modules or themes such as Webform might implement their own html5 required attribute and leaving 'formnovalidate' in leaves that functionality intact.
Comment #108
gaurav.kapoor commentedComment #110
idebr commentedApparently FormTestRequiredAttributeForm was used in multiple tests. I have left it in, but renamed it to prevent confusion.
Comment #111
idebr commentedThe 'required' attribute is also set in the States API, so I have removed that as well.
Comment #113
idebr commentedThis should fix the failing tests.
Comment #114
mgiffordThis seems to work fine for me. I just went to /node/add/article & hit submit. Did the same for /admin/structure/types/add
This doesn't seem to be enough testing by any means.
What else would be tested with this patch before marking it RTBC?
Comment #117
jefuri commentedThe previous patch form #113 could not be applied so this is a reroll of the patch against Drupal 8.4.x, but also against 8.5.x since 8.4 is already in alpha.
Comment #118
jefuri commentedComment #120
dmsmidtI can confirm the issue raised in #105 is valid and a major concern for everybody, so it is not only about accessibility anymore.
@andrewmacpherson and I sat, and discussed this at Vienna 2017. If this where a task, we could consider it critical.. So maybe a framework manager can help us out here to help us decide.
There are multiple other concerns (as outlined #98) and a bunch of bugs due to HTML 5 validation.
For example 'chosen' enabled selects don't work anymore, errors can be below the toolbar, or show up at the wrong place (#2787179).
The current patch only gets rid of some of the problems around HTML 5 errors, namely for required fields. But it is also possible to get other HTML 5 errors (e.g. incorrect e-mail format), so it is not a complete fix.
Furthermore, I expect that there are a lot projects in the wild that use the 'required' attribute. So removing that could potentially break error styling and other JS related things. So could we consider that a BC break?
Like we discussed before, and had a lot of yeah sayers, we should probably just go back to the 'formnovalidate' attribute for all forms and disable HTML5 errors. It's the smallest change and resolves a lot of actual problems. We could think about a JS/client side layer in a follow up.
Comment #121
lauriiiThank you @dmsmidt for reaching out for me. We had a chat about this at DrupalCon Vienna and I suggested that instead of making the change for all forms globally, we would do it only in Seven and Bartik. If we would change this more globally, this could break existing applications since they might rely on HTML 5 form validation. This would fix the bug in our product, and any other themes could implement the same if they wish.
I think the best approach would be to use the
formnovalidateattribute since the required attributes could be useful for other purposes as well.Comment #122
Anonymous (not verified) commentedComment #123
Anonymous (not verified) commentedAdded a (hopefully) working version of the patch for 8.3.x. Someone else had tried to do so but ended up mixing a load of other stuff into it, so this should be a clean one #122
Comment #124
Anonymous (not verified) commentedSorry, previous patch had my /docroot in it, so this is a bit cleaner
Comment #125
mgiffordThanks for the patch @Maffoo - just sicking the bots on it.
Comment #127
yogeshmpawarComment #128
yogeshmpawarUpdated patch because previous patch failed to apply on 8.5.x
Comment #129
skaughtthis patch is only altering /core/misc/states.js, not to /core/misc/states.es6 first, then compiled back.
#2815083: Drupal core now using ES6 for JavaScript development https://www.drupal.org/node/2815083
Comment #130
GrandmaGlassesRopeMan@SKAUGHT - Thanks for noticing that. 👍
Comment #131
geek-merlinHere's a quick 8.4.x backport for all that need it.
Everyone else: PLEASE IGNORE.
Comment #133
idebr commentedThe approach in the latest patch removes the
requiredattribute. However, the suggested approach by dmsmidt and lauriii in #120 and #121 is to implement theformnovalidateattribute so browser skip html5 validation altogether.Comment #134
jrockowitz commentedI was working on #2947101: Premature error message is announced in the Webform issue queue and found this issue.
I read through this thread and conclude that if a form needs to be fully and reliably accessible, HTML5 client-side validation needs to be disabled and the required attribute removed from all inputs. I think it is little awkward to disable only HTML5 clientside validation for just 'required' inputs and still have it enabled for HTML5 email and URL inputs.
Personally, I would argue public-facing forms just can't use HTML5 client-side validation if they want to be fully accessible, but admin 'internal-facing' forms could still use HTML5 validation. For example, HTML5 client-side validation enhances the user experience when building a webform. The decision to enable/disable HTML5 client-side validation depends on the website and use-case.
So the Webform module for Drupal 8 does allow clientside validation to be disabled, so I decided to experiment with removing the required attribute via JS using the input focus event and seeing if the input's form has the 'novalidate' attribute. Parts of this approach could be applied to #states API.
One compromise might be if the 'novalidate' attribute is set on a form, the 'required' attribute is not added to any input. By default, the 'novalidate' attribute should be enabled/added to all forms but themes, especially admin themes, could provide a mechanism to enable HTML client-side validation.
Comment #135
bkosborneI don't think the required attributes need to be removed. Adding "novalidate" to the form element prevents the required attribute from doing anything in my experience.
Comment #136
mgiffordI updated the links in #44 to point to:
http://fnagel.github.io/jQuery-Accessible-RIA/Form/
http://wet-boew.github.io/wet-boew/demos/formvalid/formvalid-en.html
Comment #137
idebr commentedNew approach based on the suggestion of dmsmidt in #120 and lauriii in #121 to disable html5 validation altogether on the
<form>element.The correct attribute on the form however is
novalidate, see https://developer.mozilla.org/en-US/docs/Web/HTML/Element/formThis implementation matches the Webform implementation of disabling client side html5 validation, see #134
Comment #138
andrewmacpherson commentedI like the direction of patch #137, haven't manually tested it yet.
Re #121:
It's a shame we have to restrict this to certain core themes. Does that effectively mean we're stick with this problem more generally until D9?
Needs work: the Umami theme should get this too.
Comment #139
hass commentedShould be done for all forms in all themes. No idea why any theme should be excluded. This is not theming.
Thanks for sharing the idea. Form message tracking is currently broken in Google Analytics/Matomo without this fix.
How soon can we get this onto core?
Comment #140
geek-merlinThis should be theme independent: system_preprocess_form.
Comment #141
fenstratMoved to system_preprocess_form. Seems to work well, really nice idea.
Comment #143
idebr commentedIf every form is to have the
novalidateattribute by default,template_preprocess_form()would be a more suitable place to do it.template_preprocess_form()also assigns a default 'accept-charset' attribute, so it would make sense to add other default attributes there as well.Comment #144
effulgentsia commentedAre there any public statements from the WCAG working group that recommend this? E.g., I don't see anything in https://www.w3.org/WAI/GL/wiki/Techniques/HTML5/Using_the_required_attri... that recommends this as preferable to letting html5 validation run. If we're finding that html5 validation is not accessible, should we be working with WCAG for them to issue a public statement and recommendation about that?
Comment #145
fenstrat@idebr sure, good idea.
@effulgentsia good question. I'd defer to others on how to approach WCAG.
Comment #147
andrewmacpherson commentedRe: #144
"Techniques/HTML5/Using the required attribute to indicate a required input field" only covers the basic scenario of a required field, with no other HTML5 constraints. Other client-side validation techniques relating to WCAG SC 3.3.1 Error Identification still kinda assume we're going to put our own client-side alert mechanism in place. I expect we'll eventually do that in the JS Admin UI initiative, but the simplest way to address this accessibility problem for the current Twig-based UI is to move all validation server-side.
I think it would be good to do another round of manual testing with a broad range of browser+OS+AT combinations. This issue is 6 years old now, and we should check if it's still relevant. We'd want to find out what progress there has been with HTML5 validation (outside of Drupal), and find out what we can about known bugs and/or implementation progress with browsers, OS-level accessibility APIs, and assistive tech. In other words, how many platforms satisfy the WCAG notion of "accessibility supported", with default user-agent validation?
If enough do, then maybe we could drop this issue. Older versions of assistive tech are still widely used though, so it's a tough judgement call either way. On the other hand, if the situation hasn't improved much, then we should proceed with turning off client-side validation.
I'd like more detail about the per-theme implementation issue (comments 121, 138-140) and whether we're stuck with this until D9. But even if we can only fix it for Seven (and Bartik), it would be a HUGE accessibility win for the meantime. Contrib admin themes can do this too.
I did some tests on a required text field, with the latest browsers and screen readers on Windows 7. Here's what I found so far...
Detailed results in attached text file (including some JAWS bug report links). There's still a lot more still I'd like to test, and it's quite laborious :-(
TODO:
Comment #148
geek-merlinI can confirm that there are still major and maybe unsolvable issues with invisible html5-validated form elements (see #2787179: Ensure visibility of invalid fields (JS)), e.g. in tabbed or accordion forms, at least in firefox and chrome.
Comment #150
mpp commented#148, in the case of hidden elements, instead of removing html5 validation, we could listen to the 'invalid' event and show the proper tab when there's an error.
Comment #151
geek-merlin#150:
> we could listen to the 'invalid' event and show the proper tab when there's an error.
Good thought. But how can this work out if we have multiple errors in different tabs?
Comment #152
mpp commented@axel.rutz, we'd show the first error, just like HTML5 validation itself.
Comment #155
skaughtComment #156
liquidcms commentedSafe to assume this is the same issue?
On 8.8.1 using Seven, I submit form to create a new user and in a closed vertical tab there is a required field which has not been filled in. The form's response is nothing. Nothing is submitted to server; there is no error of any type and the form page does not move from the original spot where the submit button exists. In other words, it appears as though I have not clicked the button.
Great that this is marked as an accessibility issue but much more severe as it is a major UX fail. Not sure how this wasn't a Drupal 8 release blocker.
NOTE: I assumed there was no way this was actually broken in 8.8 so figured it must be interference by some contrib module; so tried with a new (8.7.7) install and it still fails. Yikes.
Comment #157
mgiffordI'm just chiming in as @liquidcms brought this issue to my attention again. This is a D7 regression. This should have been a priority issue to address in Drupal 8. Can we see that this is a release blocker on D9?
I've been out of the loop for a bit, but @andrewmacpherson added a good comment with todo items a year ago and there have been some follow-ups since then.
We can start by someone re-rolling @fenstrat's patch in #145.
Comment #158
acbramley commentedPatch in #145 still applies cleanly to 8.9.x so no reroll necessary as of yet :)
Comment #159
wim leers@acbramley I think @mgifford means that the one last failure should be fixed :)
Comment #161
sja112 commentedI have gone through the patch submitted in https://www.drupal.org/project/drupal/issues/1797438#comment-12684759.
Because we have added "novalidate" attribute in the form prefix and didn't update the test case, it is failing. I have updated the test case accordingly.
Please review.
Comment #163
sja112 commentedComment #165
sja112 commentedI have gone through the patch submitted in #145.
Because we have added "novalidate" attribute in the form prefix and haven't updated the test case, it is failing. I have updated the test case accordingly.
Please review.
Comment #166
sja112 commentedComment #167
wim leersComment #168
dmsmidtWe are disabling HTML5 validation altogether, this is a pretty big (but needed) thing and needs a change record.
To summarise (again): Drupal was never architected to work with HTML5 validation, browser changes snuck up on us and we are to deal with it because Drupals usability and accessibility both degraded.
Architecturally we have two things to consider. Drupal uses serverside:
- (Twig) rendering
- form validation
This hasn't changed in the almost 8 years since this issue has been created. This fix is in line with that setup. I know there are undertakings to change that, but those are still a while away.
With Inline Form Errors in core and increased performance of both PHP and the way Drupal works with caching I think it is fair to disable HTML5 validation until a more clientside focused architecture is in place. There are just too many drawbacks to HTML5 validation for us.
Again some problematic examples:
- analytics tooling not working (#139)
- users can't find form errors (in collapsed details elements #15) and thus can't submit some forms
- solving HTML5 error messages doesn't mean you solved the serverside validation rules
- two different types of error reporting (styling/experience)
- HTML5 validation isn't generally accessible as I understand from @andrewmacpherson
I just want to know if this approach is green for all forms and themes (@laurii, please reconsider #121), then we can even add a browsertest and make this a proper fix that is not the most happy outcome, but beter than we have.
Comment #169
skaught#168: about #121
needless to say: why would any sane developer rely on client side validation (:
In order to remove html validation then, it would make since that email, tel, number (and other like inputs) elements provide a minimal server side validation to 'replace' what was relied on.
(assuming they aren't using a complex regex as an attribute) it is true that there would be contrib todos as a result (ie: 139) -- but that should be a minor todo for any actually maintained project.
Comment #170
skaughtsecond option: add a system config to 'use html validation' sitewide, or not. -- make it easy to disable per project.
Comment #171
nod_The comment about developer's sanity is unnecessary, the principle of client side validation is not in question here.
Since there was no progress over the years, I agree we should disable html5 validation for now. If people want to use html5 validation they can always modify the render array, or remove the attribute in JS where necessary.
Comment #172
skaught'sanity checking' in our processes is a good reminder for everyone.
Comment #174
pameeela commentedClosed #3155808: Not able to create a Basic/Article page in drupal 9.0.0 as a duplicate so added credit for ankiitsinghh for reporting that issue.
Comment #175
skaughtworks as expected.
Example:
Comment #176
lauriiiMoving this away from the RTBC queue because there's a few needs tags that could be worked on prior to a committer review. 😇
Comment #177
tanubansal commentedComment #178
tanubansal commentedComment #179
tanubansal commentedComment #180
tanubansal commentedAlready tested
Comment #181
samiullah commentedMoving to unassigned as issue was already in RTBC
Comment #182
pameeela commentedComment #183
pameeela commentedCleaning up the tags because this patch now has tests and has been manually tested.
But it seems the approach is still up for debate based on #121, because the latest patch does make this change globally and not just in Seven and Bartik.
I have updated the IS with remaining tasks including to confirm the approach.
Comment #184
fenstratAttached is the approach from #121 moving the disabling from global
template_preprocess_form()into core theme implementations (for bartik, claro, and seven).I'm on the fence on this. I think it makes sense to fix it globally (i.e. #165). But I can also see that Lauri's comment in #121 is right, if we change it globally it could break existing applications relying on HTML 5 form validation.
I can look at adding tests for this if we agree this is the best approach.
Comment #187
baikho commentedMoving back to "Needs review" based on comment #183. I think it would be good indeed if we could get confirmation on the suggested implementation on either a global change vs only in bartik, seven, claro before proceeding with #184.
#165 also still applies cleanly against 9.2.x
Comment #188
moshe weitzman commentedI think the latest patch follows guidance from the framework manager (limit the fix to core themes). However, it has test failures so can't yet be moved to RTBC. Hopefully someone can clear those.
Comment #190
rinku jacob 13 commentedpatch #165 applied cleanly and working as expected for drupal 9.3.x , sharing screenshot for reference.
Comment #191
skaughtAdding tag for D10.
re: "limit to core themes" would this still be insight. this is causing bike shedding of this issue.
just a general point: Since D8, i have had ZERO clients report they approve of "how that styling looks'. starting right at the /user login form.
Comment #193
socialnicheguru commentedwhen patch in 184 was added to Drupal 9.2.12 submit buttons did not work on any forms
i went to add a content type, test.
I type in title
I hit save button and the page just refreshes
this happened on all pages on my site.
Comment #194
skaughtagree. i don't think 184 is on the right path. somewhere here is seems people are only disabling validation on 'some form' -- not ALL forms across core.
it makes no sence to only disable in core themes. the goal should remain to make the entire app meet the goal.. yes, conrbrib projects may have their own related follow up once this become 'the new norm'. reminder: validation was thrown on suddenly when d8 was late, late prerelease (:
Comment #199
kieran.cott commentedThis patch is identical to that in #165, but with line numbers updated for compatibility with Drupal 9.4.8.
Please disregard #197 and #198.
Comment #200
suresh prabhu parkala commentedPatch did not apply. Re-rolled the patch. Please review.
Comment #201
mgiffordAdding tag for WCAG SC 3.3.1
Comment #202
fenstratI've queued #200 for retesting as the failure in Drupal\Tests\ckeditor5\FunctionalJavascript\MediaLibraryTest::testButton looks random.
Comment #204
smustgrave commentedReviewing the remaining tasks
Was this decided? Personally I think on a per theme basis makes sense for backwards compatibility but that's just my option
Comment #205
smustgrave commentedOr what if this was gloabl theme setting that users could opt in and out of?
Then maybe can write some upgrade path for sites to choose to disable or not?
Comment #207
steinmb commentedReviewing form API and found #2203649: Remaining Open Form API related Accessibility Issues that took me here. This issue looks like it stalled, anything people can do to move it forward?
Comment #209
skaught- moves #200 into gitlab.
- #202 fail is not happening now!
Comment #210
skaughtComment #211
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue.
While you are making the above changes, we recommend that you convert this patch to a merge request. Merge requests are preferred over patches. Be sure to hide the old patch files as well. (Converting an issue to a merge request without other contributions to the issue will not receive credit.)
Comment #212
nod_Comment #213
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #214
nod_The 11.x branch from the issue fork seems wildly out of date, need someone to merge origin/11.x into this branch
Comment #217
skaughtI did pick up from that branch started a year ago. I was actually getting some gitlab errors trying to start a new branch a few hours ago and some problems trying to push to that branch. New branch started for this PR.
Comment #218
skaughtreset tag
Comment #219
skaughtWhat seems more correct is that html5 validation is first.
q:
- why is IFE a figurehead module now that just re-threads individual notices
- why do forms not just support 'ajax first'
The Contact Form is a simple public example where this approach hurts first. Not that this equals issue title severity.
Standard Profile/IFE-less: of course, the Message System would just be 'content top' as initially explained.
Then, into node forms examples where we this effects deepens. (ie: details elements , vertical tabs (with details).., entity references with Inline entity forms, ajax form responses (get lost to user).
Comment #220
steinmb commentedFound note on order reading up on #1797438: HTML5 validation is preventing form submit and not fully accessible
Edit: haha, I need more coffee. Mange to create an circular dependency in this issue 🙄
Comment #221
skaughtcircular dependency. omg yes. cheers.
More than just NOT NULL:
I think the goal of 'using javascript' was meant to be that 'patterns' for inputs would be able to 'store all the form or entity validation' to. which we know can be complex (multiple Constraints, validation/form alters afterbuilds, etc.). Which Drupal forms (still) can not provide to pattern attribute (to just regex..).
the goal was to use 'front end js validation before submit'. Thus, we have a much shorter path with forms being 'ajax first'.
i understand that in the early d8 timeline with [IFE NESTED errors] Containers, details/fieldsets had been completely rebuilt and had more bugs around IFE (while it was still experimental in core in D8). needs clarification for this, of course.
Comment #222
smustgrave commentedLooking at the issue summary and the MR they don't appear to match. Also not entirely sure the test changes counts as checking the issue.
Moving to NW for that and the CR (if still needed)
Comment #225
anybodyNow that #2787179: Ensure visibility of invalid fields (JS) is fixed, please check if this issue still appears and if changes are needed here. I'm reducing priority as I think it might be fixed or mitigated by #2787179: Ensure visibility of invalid fields (JS)EDIT: Sorry I glitched into the wrong issue, though I was in field_group ;)
Comment #226
anybodySorry I glitched into the wrong issue, though I was in field_group... The title was nearly the same.
Comment #228
xjmAmending attribution.
Comment #230
kentr commentedBased on #120, #121, #168, #171, I updated the Proposed Resolution.
RE tests
There are currently several tests for validation error messages in
core/modules/system/tests/src/Functional/Form/ValidationTest.php, but they are not failing. I am assuming that the standard browser simulator doesn't support HTML5 validation, and so the problem has been disguised.To correct this, in the MR I moved some tests from that file to a new FunctionalJavascript file. Those tests will now fail with the current code and pass with the changes in the MR. They check more than simple required fields, and check for multiple error messages.
Still outstanding
The question of whether to make the change globally, or only in core themes.
Gin also suffers from this (and by relation, so does Drupal CMS?). The Gin maintainers have marked it Won't Fix, stating that it should instead be addressed in core.
Comment #231
mgifford@kentr I'd say that we make this change globally. If it were only in core themes it would be confusing. I'd agree that this should be fixed in core, and as such the Gin maintainers were right in having it marked it Won't Fix.
Would be nice to fix this bug before it turns 13.
Comment #232
kentr commentedThanks @mgifford. The current MR is a global change (MR 7458, started by @skaught).
I'm removing Needs issue summary update because I believe my changes resolved the points from #222.
Comment #233
kentr commentedActually, #222 was also NW for the change record.
Comment #234
shubham_pareek_19 commentedAdded the change record please review!!
Comment #235
nod_Please be careful to not publish the change record if the issue is not fixed.
Comment #236
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #237
kentr commentedI rebased the MR and made a couple of minor changes on the CR draft.
The conflict was due to the deprecation of
template_preprocess_form()in #3534334: Convert template_preprocess in form.inc, so please check that I put thenovalidatechange into the correct new place.Comment #238
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #239
prudloff commentedI rebased the MR.
Comment #240
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #241
prudloff commentedI rebased the MR.
Comment #242
oily commentedRe #230, test coverage is present. Output of test-only:
This looks good.
Comment #243
smustgrave commentedShouldn't this be configurable? Settings flag maybe?
Comment #244
prudloff commentedHaving a setting for this could be a good idea.
We noticed on our websites we sometimes want the HTML5 validation and sometimes don't, it is basically a tradeoff:
So letting each website decide what to use could make sense.
Comment #245
smustgrave commentedI know the webform module has a specific setting for this.
Comment #246
skaught2 cents:
A. "important for users with slow internet speed."
tied around 'low powered servers' >> is a business problem, not a cms problem!
- we can never know the end users network realties this should not be a lead concern if a user can not submit the form information that is the key goal -- to have saved info, not relative speed of validate/submit that would be 'low concern' from any business need/decision. global/country limits... local service problems or an EMP pulse from space.
..sorry for the mini-rant. but if they don't know why a field can't be submitted then their first load of a page (a non ajax form) was a waste of time for that user to fill out the form at all, for business concerns alike.
last thought: I get that this concern was high in 2012 (when this ticket started, when core itself activated this..) -- we were still coming off of IE6 support in websites.., pre G5/6 speeds, early iPhone/iOS.. etc.
B."Shouldn't this be configurable? Settings flag maybe?"
- myself in past project i had an alter to keep html5 validation active in public pages, by then NOT on admin forms -- as this problem is huge if you are using tools like https://www.drupal.org/project/inline_entity_form on a 'node of nodes..' Similar as Paragraphs related submits.
^ this is also due to the complexity of theming form errors in public branding when there was never any approved design (for form errors, extended: IFE use).
^ option per theme.
Comment #247
jcandan commentedI've fired up a community initiative that may be related to this issue:
Field Required Context Initiative
Comment #248
prudloff commentedThis is also something we had to do on some websites but I'm not sure that's something core should support.
Doing this in contrib would be quite easy.
Comment #249
smustgrave commentedLet me know if I’m wrong but seems like this still NW. Specifically a way to configure it. Personally I think it should remain as is and the configuration should allow you to opt certain forms out.
Comment #250
jcandan commentedJust linking to the initiative in #247 was a poor sell on my part. With your permission, allow me to throw this out there with more pizazz.
Field Required Context Initiative, and soon its API module, is my very recent attempt to define a shared, context-aware notion
of “required” in Drupal--for example, required on publish but not on draft, required only
during specific workflow transitions, or minimum completeness rules for composite fields.
At this stage, the initiative is a coordination effort and the module is essentially
API scaffolding. They do not change core’s HTML5
requiredbehavior, do not add UI,and are not yet integrated with other contrib modules.
This work is relevant here because it directly addresses the practical problems
that have prevented this issue from being resolved for more than a decade:
The Form API only has a binary field-level required flag. Without a richer model,
core cannot safely decide when an asterisk should be shown, when HTML5
requiredshould be emitted or suppressed, or when server-side validation should run.This blocks legitimate submissions in workflows where fields are optional in one state
and required in another (e.g., drafts, transitions, conditional logic, or
“Required on Publish”), but core currently has no mechanism to express that distinction.
HTML5
requiredhas no notion of “minimum completeness,” and contrib currentlyimplements one-off solutions that cannot coordinate with core.
Modules such as Require on Publish, Conditional Fields, Webform, Migrate, and
workflow systems all reimplement their own ideas of requiredness because core
does not provide a place to register or evaluate state-dependent rules.
Because of these constraints, patches proposed in this issue have repeatedly run into
the same problem: core cannot alter its use of HTML5
requiredwithout an underlying modelof when a field is required in a given context. The result is that any fix risks breaking
draft workflows, moderation systems, conditional logic, and composite field behavior.
The Field Required Context Initiative does not resolve this issue today, but it is
attempting to provide the missing abstraction layer that a proper fix would depend on:
a centralized API through which core and contrib could consistently determine
requiredness and then apply UI indicators, HTML5 attributes, and server-side validation
in a coordinated way. Without something like that foundation, this issue is unlikely to
be solvable in a durable way.
I hope you'll consider hopping into the initiative in some way.
Comment #251
jelle_sPatch file of the MR for those who want to use it with composer.
Comment #252
kentr commentedRE configuration, it looks like there's more support than opposition.
Due to the concern about BC break, should we default the setting to keep it as-is at first and then change the default later?
Comment #253
kentr commentedI rebased the MR, added
#[RunTestsInSeparateProcesses]to a test class, and add the configuration option to the proposed resolution.Comment #254
kentr commentedI added a first draft configuration named
core.form.enable_html5_validation, under the premise that core's stance is to use server-side validation.Please review whether it's the right approach.
Adding needs tests b/c IMO the test should check both cases (enabled / disabled).
The configuration can only be changed in
settings.php. If it needs to be exposed in the UI, is it acceptable to do that in a followup?Comment #256
needs-review-queue-bot commentedThe Needs Review Queue Bot tested this issue. It no longer applies to Drupal core. Therefore, this issue status is now "Needs work".
This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.
Consult the Drupal Contributor Guide to find step-by-step guides for working with issues.
Comment #257
kentr commentedI'll rebase.
Comment #258
kentr commentedRebased.
Still needs tests, but I'd like feedback on current MR.
Comment #259
smustgrave commentedSo I think for this one we need to default $element['#attributes']['novalidate'] to FALSE with some kind of deprecation, probably on the status report page like we for static.cache that says it will eventually be defaulted to TRUE. This is disruptive enough I'd say the deprecation should be set to Drupal 13 (which we have started to do for other things).
We can't just turn this off on people cold turkey have to give people time to adjust.
Maybe could be contrib but think we need a way to opt in or out certain forms vs all or nothing. But goes back to my points above of waiting till 13 to make it default to TRUE. Allows contribution space time to get support in place.
Comment #260
kentr commentedMakes sense.
Would it be sufficient to keep the attribute based on a setting, but have the setting default to the current behavior? This way, developers / site builders can opt in.
If we put it into core now as experimental (defaulting to the current behavior), it can be tested to assess how extensive that fine-tuning needs to be.
Comment #261
smustgrave commentedI think that perfectly makes sense.
Comment #262
kentr commentedOk. I'll work on the changes.
Comment #263
catchMaking this based on a setting seems OK, but I think we should remove the setting eventually.
Could we:
- default the setting to off in 11.x
- default the setting to on in 12.x
- remove the setting in 13.x
?
Or if that's too disruptive, we could bump the 12.x/13.x to 13.x/14.x
I briefly thought about a feature flag module for this, but that might be a bit much for this case.
Comment #264
smustgrave commented@catch so the idea would be to do something similar that we did for static.cache. Where it'll have a warning on the status report page and then in 13 we remove. Or as you said in 13 make it default to on and remove the setting completely in 14. I've considered it but I may write a contrib module that will let users turn it on so if I get that done maybe we don't need ot wait for 14.
Comment #265
kentr commentedPersonally, the sooner the better. It's a 13yo Major general UX bug...
There are a lot of voices in the discussion to disable HTML5 validation immediately in one form or another, at least as far back as 2017.
@dmsmidt (#120)
@lauriii (#121)
@andrewmacpherson (#147)
@mgifford (#157) Even suggesting that it be a release blocker for D9.
@nod_ (#171)
Instead of phasing the configuration change, we could do the core themes immediately and phase in a global change (possibly still behind a configuration). Themes / developers can make their own choice.
Comment #266
smustgrave commentedComment #268
smustgrave commentedComment #271
smustgrave commentedRemoving submaintainer tag because it was 6 years ago and will go on a limb as multiple core team members have chimed in since. Also removing the needs tests tag as the test-only pipeline shows the coverage https://git.drupalcode.org/issue/drupal-1797438/-/jobs/9214759
main branch is all green!
Cleaned up the CR to the best of my ability but could use a 2nd set of eyes.
11.x branch is having some issues so leaving in NW.
Comment #272
smustgrave commentedI forgot the most import tag :)
11.x branch is now passing too
Also FYI idk why I was having some rebase problems on the original MR that's why I started a new one.
Comment #273
smustgrave commentedReady for some eyes
Comment #274
kentr commentedI noticed that the status page warning doesn't appear if the setting is unset, which happened because I didn't put the new setting into my existing
settings.php.If we're planning to eventually remove the setting altogether and always disable HTML5 validation, do we want a warning to appear even when it's unset so that the full removal doesn't catch people off-guard just because they neglected to add the setting in an previous upgrade?
Or is that a problem to be solved later?
I also tweaked the IS a little.
Comment #275
smustgrave commentedUpdated 11.x branch.
Comment #276
dcam commentedI left review comments on both MRs. In particular I think the text of the D11 MR needs work.
This may only be my opinion, but I think we need to ensure people know this setting is going away. I put it in the suggestions I made. If it's agreed that it's important, then it also needs to be added to the change record. Also, the second-to-last sentence needs a period at the end.
I'm setting the status to Needs Work for my suggestions to be considered.
Comment #277
kentr commentedWorking on @dcam's suggestions.
Comment #278
kentr commentedI think I completed @dcam's suggestions.
Also tweaked the CR. This line might need some adjustment, or possibly removal. My understanding from the discussion is that they can be localized through the browser's language settings (#47), and customized with the
oninvalidattribute (#23) but we decided not to use it (#31).AFAICT these are the expected results. Can someone confirm and add to the IS?
NULL/ missingFALSETRUENULL/ missingFALSETRUEComment #279
kentr commentedNW for @CharlesBelov's comments on the MR.
Comment #280
kentr commentedI addressed latest MR feedback.
Also updated the IS for #278. Pretty sure it's correct.
Comment #281
kentr commentedComment #282
kentr commentedComment #283
dcam commentedIMO this is really close. I left a few suggestions that I feel clarifies the requirements text and gives people something to act upon. Please consider them.
Comment #284
kentr commentedLooking into @dcam’s comments.
Comment #287
oily commentedLeft one MR unhid, the one that merges Main branch. Might be a mistake as the other MR may be in progress too?
Pipeline is running green. Output of test-only:
https://git.drupalcode.org/issue/drupal-1797438/-/jobs/9382706
LGTM.
Comment #290
dcam commentedYes, the 11.x MR is valid and needs to stay active. It contains separate changes from the main MR.
Comment #291
kentr commented@dcam I applied your suggestions for the
descriptionproperty but put a question on the MR about thevalueproperty.Updated the IS with the new status page
descriptiontexts.Comment #292
smustgrave commentedTook a shot at saving credit since it's a ton of comments.
Comment #293
dcam commentedThe status messages work as I expect in both MRs in all conditions. I checked the table in #278 and the IS. The information there looks good. All feedback has been addressed. All threads on the MRs are closed. Let's send it up.
Comment #294
acbramley commentedDon't want to change status but I have left a comment on the MR.
Otherwise this is looking good.
Comment #295
kentr commented@acbramley I replied to your comment.
Comment #296
kentr commentedI didn't intend to change the status.
Comment #297
acbramley commentedThanks @kentr that makes sense, however IMHO it would be better to leave those tests where they were and implement something specific to testing disabled HTML5 validation in a javascript test.
Comment #298
mgiffordThis issue is over a decade old @acbramley - I wonder if that could be done in a follow-up issue so that we can resolve this issue. Unless someone wants to propose a simple patch that can be quickly reviewed.
Comment #299
kentr commentedSince it's RTBC, I was waiting for committer input before making the change. I wanted to avoid another review iteration.
Comment #300
acbramley commented@mgifford that's exactly why I didn't change the status :) Just something I thought was worth pointing out, but not worth holding up the issue on.
Comment #301
alexpottFixing attribution / contribution credit since #228
Comment #302
alexpottCommitted d5babbb and pushed to main. Thanks!
Committed 5fdaad8 and pushed to 11.x. Thanks!
Comment #308
quietone commentedcorrect branch and version on the change record