Note: Don't test this issue in Firefox and Internet Explorer, they seem to have their own support for detail boxes. Safari, Chrome and Yandex need this patch. (See #2346773-61: Details form element should open when there are errors on child elements
When I create an article node by filling in title and body fields, and deleting time from authoring information, I see an error message after saving. However the system doesn't shows any information about the mistake or the problematic field, as the details element is closed, and it does not put any error class on it. Please see the attachment. In my opinion the minimum requirement would be to open details element so the user will be able to see the reason of problem.
Before:

After:


| Comment | File | Size | Author |
|---|---|---|---|
| #118 | 2346773-118-open_details_on_error_8_2_7_backport.patch | 7.64 KB | ryan.ryan |
| #103 | 2346773-103-open_details_on_error.patch | 2.08 KB | andrewmacpherson |
| #103 | interdiff-2346773-97-101.txt | 663 bytes | andrewmacpherson |
| #97 | 2346773-97-open_details_on_error.patch | 2.1 KB | dmsmidt |
| #39 | 2346773-39.patch | 2.24 KB | ptsimard |
Comments
Comment #1
flyke commentedI confirm this bug, more info:
- If you delete both date and hour information and save: no problem.
- If you keep the date part but empty the second part (hours, minutes seconds) textfield and save, then you have the error message 'The ... date is invalid. Please enter a date in the format 2014-09-29 13:54:49. '
-> so on save, if second textfield is blank it should fill in hour:minutes:seconds of time of saving.
Comment #2
estoyausenteReally, I think that all fieldset or hidden component with errors inside should be shown outspreaded. I'm going to take a look, I'm not sure if I can do this task, but I think that is very nice appreciation.
Thank for the report.
Comment #3
estoyausenteI don't find the correct place for putting the "open" attribute to details tag. I suppose that you can add it in the validate function or in the detail render if some of the rendered element have error... but I tried to find it and it was imposible for me. I will follow this issue and learn if any resolve it.
Comment #4
klakegg commentedPatch attached, working as described in comment #2.
Comment #5
rade commentedI'll review this.
Comment #6
rade commentedDid manual review and the patch works as intended. I updated the issue summary with some screenshots.
Waiting for testbot results before marking as RTBC.
Comment #7
klakegg commentedFound an error in the patch - new patch. Error occured when patch is applied and user tries to edit an content type.
Comment #8
estoyausenteI tested and it's run ok. I think that can be maked as RTBC.
Comment #13
dmsmidtUpdated title, to be more specific.
This issue is also a problem for #1493324: Inline form errors for accessibility and UX.
Comment #14
xjmSo this issue is actually much worse with #1493324: Inline form errors for accessibility and UX. As I mentioned in #2504847: [meta] Roadmap for stabilizing Inline Form Errors module (IFE):
Promoting to major. I considered whether it should be critical, but it is still possible to use the form. It's just difficult.
Comment #15
bojanz commentedThere's another related problem here, if you set an error on an element that has children, the children will (incorrectly, #2509268: Inline errors repeated on child elements in module uninstall form) show the errors, but the parent element (for which the error was actually set) won't. If you change the #type to 'fieldset', the error starts showing up.
EDIT: The same problem persists if type is "container". Opened #2512306: Inline errors not shown for details elements.
Comment #16
Bojhan commentedI don't really see how this was not a problem before. The only thing lacking here is an error style on these detail state right? I am unsure why that would be hard to solve.
Comment #17
mgiffordComment #18
hass commentedLooks like I opened a duplicate of this here.
Comment #19
lokapujyaavoid some errors.
Comment #22
hass commentedI wonder how this should work for #18. You cannot show multiple vertical tabs and this may require some JS code, too.
Comment #23
bleen commented@hass... Re #18, I don't think there is a need to show multiple v tabs, just to indicate that there is an error by making the pages v tab (in that example) red to indicate that an error can be found in that v tab
Comment #24
alvar0hurtad0The reroll is done, so IMHO the best is removing the tag.
Comment #25
xjmComment #26
lokapujyaThere may be a better way to go about this, but for now just avoid more errors.
Comment #27
lokapujyaComment #28
lokapujyaIt's cool that the patch passes tests now.
It just seems weird to do this. Isn't there some other way to access the widgets?
Comment #29
yoroy commentedTesting on simplytest shows that the patch works for Seven theme. I put in a path alias without a slash and changed the author to a username that doesn’t exist in the system. Even if you then manually close those sections before hitting save they show expanded with the error messages on top:
It does not work in Bartik with the vertical tabs, there is no indication that something is not right inside a given tab.
Similarly, it doesn't work in Stark but that may be by design?
So it works with detail sections but not with vertical tabs, are vertical tabs in scope for this patch?
Comment #30
lokapujyaWell, with vertical tabs, only one can be open. Do you think you can adjust the patch so that it marks the the last tab with an error to be "selected"?
I tried the below, but it didn't work
Comment #31
lokapujyaIn this same file, I noticed that we need to do this:
Comment #32
yoroy commentedFor vertical tabs I like the suggestion in #18. If we decide to tackle these in here that's fine, maybe needs an updated issue title then.
I don't code, so no updated patches from me :)
Comment #33
arunkumarkHi,
Patch works fine for Me.
Comment #34
tim.plunkettStill needs tests.
Comment #35
lokapujyaJust getting tests started. Probably is a better place to put them?
Comment #36
lokapujyaComment #38
ptsimard commentedwill try to look at this
Comment #39
ptsimard commentedTrying a simple reroll to get things going again.
Comment #41
ptsimard commentedSo after some testing, it doesn't seem to be working.
code never reaches
in
Comment #42
lokapujyaFor some widgets, at least for path alias, the
If statement array structure needs to be:
not
Comment #43
andrewmacpherson commentedComment #44
ptsimard commentedSo I've spent a few hours debugging this patch the other day. I don't know how to fix it just yet but maybe that can give someone a clue.
Here is what I found:
['#errors']would always be NULLuid][0][target_idbut it has no children and/or an easy way to target it in this loop?Comment #45
lokapujya@ptisimard, this might work. Although, there might be a better way for us to know which array structure to check for errors that I am not aware of.
Comment #47
lokapujyaSee how this if statement is checking 3 different parts of the array structure for errors. Why aren't the errors in a consistent part of the array. Furthermore, is there a way to ask the widget where the errors are stored or is this an ok way of testing for errors?
Also, maybe the isset() != can be simplified to empty()
Comment #48
lokapujyaThe current failure: Need to first login as admin user.
Comment #49
dmsmidtComment #50
dmsmidtComment #51
dmsmidtThank you @lokapujya, your work has greatly improved my insight in the underlying problem.
No there is currently no standardized way of getting to know if children have errors. So to be able to solve this issue cleanly I opened another issue, that fixes this: #2754977: Enhance formErrorHandler to include children errors on RenderElements.
If the above gets in we can easily fix this issue with the following patch. This is a new approach, so I didn't make an interdiff.
I'll look at a test later.
Setting this back to 8.2.x because this is blocked by a data model change.
Comment #52
dmsmidtPlease test existing tests CI.
Comment #54
dmsmidtTest combined with new version of #2754977: Enhance formErrorHandler to include children errors on RenderElements.
Comment #55
dmsmidtComment #57
dmsmidt*Crazy* me, I combined the old version, hopefully this one is oke.
Comment #59
dmsmidtFound out (together with @Getekid) that Firefox has some own magic to open the details if it found errors (even without the patch).
Chrome however for example isn't that smart.
Comment #60
mgiffordIs it worth opening an issue in Chrome to highlight the problem? We should test this in IE & Safari.
Comment #61
dmsmidtMore detailed research for: which browser opens the details element automatically and which do not when there is an error on a child field. (note: without patch).
Does:
Does not:
So this patch is still relevant!
Comment #62
dmsmidtComment #63
mgiffordSo do you need help to fix the failing test? Thanks again for all your work on this @dmsmidt
Comment #64
dmsmidt@mgifford, thanks for the offer, but @Getekid was writing and fixing tests for this issue (I was mentoring him about this at the drupaldevdays in Milan). I've asked him to upload it. You could however help by giving a reply / review and writing a test for #2754977: Enhance formErrorHandler to include children errors on RenderElements, that blocks this one.
Comment #65
sukanya.ramakrishnan commentedAll,
when an element within a detail element is a required field, but no value is supplied and the detail element is not open, i see that the application doesnt respond. Can any of you confirm if this issue addresses that problem?
Thanks
Sukanya
Comment #66
getekid commentedHello,
Here is the test I wrote during DevDays with the help of @dmsmidt (first contribution/test)!!
In order to call the assertRaw method I had to put the whole "details" tag which might not be the best choice as another module might change it, but this way you can make sure the 'open="open"' is applied to the right point.
Hope it helps
Comment #67
skaught@sukanya.ramakrishnan
yes, a 'required' field alone does not open the details element.
tested using errorstyle.module (github) and commenting out the setErrorByName for 'test_child_custom_error_2'
Comment #68
sukanya.ramakrishnan commentedHi SKAUGHT,
Thanks for the reply. Wondering if this patch will fix that issue. basically the validation is happening currently if the details element is open and nothing happens if the element is closed. But this patch is for opening the element when the validation fails.
Should i open another issue in the queue?
Thanks
Sukanya
Comment #69
skaughtThe general process is to leave a comment and change the ticket status to 'needs work'. Listing on-going bugs is expected this way. (:
Comment #71
pwolanin commentedThis seems to still be a problem, ran into this on the path alias field.
Comment #72
dmsmidtTrigger testbot for testonly patch in #66.
Comment #74
dmsmidtNice patch failed as expected.
Working on combined patch.
Comment #75
dmsmidtCombined new test with fix.
Comment #76
dmsmidtRemoving needs test tag.
Comment #77
marcvangendI did a manual test of #75 above combined with #32 of #2754977: Enhance formErrorHandler to include children errors on RenderElements. It showed that the container containing an error does indeed open as expected. However, other containers with no errors inside open as well. See these screenshots for some examples.
Error in the URL alias. Note that Authoring Information and Promotion Options have opened too.
Error in the authored date. Note that URL Path Settings and Promotion Options have opened too.
Missing title. Note that Authoring Information has opened too.
Comment #78
marcvangend(needs work, see previous comment)
Comment #79
marcvangendFound the problem mentioned in #77. The problem turned out to be in #2754977: Enhance formErrorHandler to include children errors on RenderElements (new patch coming up), not here. This one looks RTBC to me.
Comment #80
tim.plunkett$elements = &$form;please, otherwise it looks too much like &=[] not array()
So this is an internal property that shouldn't be defined manually? Or should this merge and not set to [] and overwrite
its
Aha, so this is the actual bugfix.
Nit, but use single quotes when not interpolating.
[]
#2 is the main question, the rest are nits
Comment #81
dmsmidt@tim, thanks for the review. 2: Yes that is an internal property not to be set manually. See the blocking issue.
Comment #82
dmsmidtComment #83
marcvangendNew patch, adding the test that exactly 1 details-element should be open, no more. See also #2754977-37: Enhance formErrorHandler to include children errors on RenderElements.
Comment #84
marcvangendComment #86
tim.plunkettIf this is blocked on the other issue, it should be postponed.
Comment #87
dmsmidtIssue is blocked, see #2754977: Enhance formErrorHandler to include children errors on RenderElements.
Comment #89
pierremarcel commentedI understand it's still postponed, but I'll change to RTBC so there is an update since I did test it. Here are my steps:
I applied patch https://www.drupal.org/node/2754977#comment-11868046 tested and no changes after running that patch alone because it was for data model only.
Then applied https://www.drupal.org/node/2346773#comment-11785294 from this page and issue has been fixed. Link is linking to the vertical tab and also it's expanding it.
Tested on FF 51.0.1 and Chrome 55.0
Comment #90
tstoecklerPerhaps per #89 it can go straight to RTBC but it should still be postponed until it is no longer blocked.
Comment #91
tstoecklerBlocker is in now.
Comment #92
dmsmidtQueued latest patch for retest and requested extra test against 8.4 to be sure.
Comment #93
tstoecklerSo I guess the test failure is legitimate. There seems to be another open details element. Maybe the revision information one, because revisions are now defaulted to TRUE?
Comment #94
dmsmidtWorking on it.
Comment #95
andrewmacpherson commentedWorking on this too. It's the last "Feb 1st must have" for Inline Form Errors, so I've the afternoon off work for it :-)
I'm in #drupal-contribute and the Drupal Slack.
Comment #96
dmsmidtManual test was still oke. It was indeed the revision details box giving problems.
New test checks that after a form submit only one extra details element is open.
Comment #97
dmsmidtAh bummer, some typ0s, working too quickly ;-)
Comment #98
tstoecklerBack to RTBC.
Comment #99
pierremarcel commentedI also tested and can confirm it's good to go!
Comment #100
andrewmacpherson commentedI'm doing manual testing of patch #97 with as many browsers and screen readers as I have available. So far things look good, but I'll post my results later today. Should take me an hour or so.
Tagging needs accessibility review while I do this. I'll remove it later and put RTBC back if no problems.
Comment #101
andrewmacpherson commentedManual testing after patch #97. I'm using the errorstyle testing module. The "Details closed" element is near the bottom of the the long `/error-style/form` page.
After a standard install, and enabling inline_form_errors and errorstyle modules, you can visit
/error-style/formas an anonymous/authenitcated user and get the Bartik/Seven theme respectively. I tested both.This is the list of browsers and screen readers I tested with. FWIW my Linux is Kubuntu 14.10.
linux/Firefox 50 (not expected to show the bug, but I tested with it anyway)
linux/Chromium 55
linux/Chrome 55
linux/Chrome 55 + ChromeVox
linux/Opera 42
linux/Vivaldi 1.6
It's fine in all of these scenarios. Now I'm going to test with VoiceOver on iOS and macOS.
Comment #102
andrewmacpherson commentedTested patch #97 with these too. All OK.
There was no difference whatsoever with/without a screen reader in any combination I tested. Makes sense, this is just about opening the details elements when they contain an error; the internal form content of the details elements is not being addressed here.
Comment #103
andrewmacpherson commentedI'm done with manual testing, all OK by me.
Code review: I looked back to the previous RTBC patch in #79, and worked though the interdiffs since then, up to the patch in #97.
Points 5 + 6 raised by @tim.plunkett in #80 had not been addressed. They were minor coding standards fixes, and I've updated the patch here.
Points 1-4 in #80 are no longer relevant. They were about things in
core/lib/Drupal/Core/Form/FormErrorHandler.php, which isn't changed by the recent patches. I think Tim reviewed2346773-75-open_details_on_error_COMBINED.patchwhich included the changes from #2754977: Enhance formErrorHandler to include children errors on RenderElements.Comment #104
andrewmacpherson commentedMuch earlier in this issue, we didn't get an answer to whether the related vertical tabs issue is in scope for this issue or not. See comments #18 - #32 for details. (#2531700: Fragment links to children elements in closed grouping elements don't work) was marked as a duplicate of this one, but none of the patches here address it. The vertical tabs issue isn't mentioned in the issue title/summary, and it hasn't been mentioned here for over a year. I don't think any of the comments here mention that the other issue was closed as a duplicate of this one, or that it was in scope for this issue.
Given that:
Can we re-open #2531700: Fragment links to children elements in closed grouping elements don't work as a follow-up to this one? It hasn't been decided whether this is a must-have or should-have for keeping Inline Form Errors in core. There is still a March 1st must-have deadline for #2828092: Inline Form Errors not compatible with Quick Edit in any case.
Tagging for product managers.
Comment #105
dmsmidtAs per #104, the wrongly closed issue is reopened. I removed the tag for product manager here and added it again to the reopened issue. Also see our meta issue for details.
Patch in #103 is green again. I also manually tested it again, and it still works. So back to RTBC!
Comment #106
webchickComment #108
webchick^ That was me saving issue credit. :)
Patch is straight-forward and has tests to demonstrate it does what it says it should do. Looks like the kerfuffle up there with product manager review was meant for another issue.
Committed and pushed to 8.4.x! Tentatively marking RTBC for 8.3.x backport as well, after code freeze.
Comment #110
tstoecklerComment #111
damienmckenna@webchick: You say "Tentatively marking RTBC for 8.3.x backport", is there anyone that needs to be convinced it should be committed, or is it simply an hours-in-the-day problem?
Comment #113
webchickOk, cherry-picked to 8.3.x as well.
Yeah, mostly hours in a day problem. I had time on that day, but that day we were in 8.3.x code freeze. :)
Comment #114
damienmckennaThanks @webchick! <3
Comment #115
xjmCorrecting issue credit.
Comment #116
damienmckenna@webchick, @xjm: I am sincerely sorry for my impatience in #111 :-(
Comment #118
ryan.ryan commentedJust to report on an attempt at an 8.2.7 backport and the work in progress, I applied this patch and tried to include necessary code dependencies to make it work. I wasn't successful, but here's the non-working in progress 8.2.7 patch, in case someone wants to pick it up. We ended up using the in-progress contrib solution here https://www.drupal.org/node/2787179#comment-11877050 which is working.