Closed (fixed)
Project:
Field Group
Version:
8.x-3.x-dev
Component:
User interface
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
12 Jul 2017 at 13:13 UTC
Updated:
31 Oct 2021 at 09:34 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
BarisW commentedHere's a patch that implements this.
Comment #3
BarisW commentedApologies, the patch misses the use statement.
Comment #4
BarisW commentedNot sure why the test fails, but it is not related to my patch for sure.
Comment #5
acrosmanOn the 8.x-3.x-dev branch I'm seeing a similar behavior in that if there are any errors outside the visible tab the form does not post, nor do any errors appear. Unfortunately the current patch here (which does apply cleanly that that branch) didn't resolve the issue.
Comment #6
acrosmanComment #7
geek-merlinComment #8
geek-merlinComment #9
chrisolofSeems to work for top-level details elements. Anything more complex is left closed. Seems like we'd want to ensure any field group at any depth containing validation-failing elements would be rendered open.
Comment #10
chrisolofJust a note that the patch in #3 applies to 8.x-3.0-beta1, but not the current 8.x-3.x branch. In attempting to improve the patch with recursion and bring it into compatibility with 8.x-3.x I found that the technique in patch #3 no longer works (looking for the presence of '#children_errors'). It seems that the error-state of form elements is no longer part of the $rendering_object/$processed_object in Drupal\field_group\FieldGroupFormatterBase or Drupal\field_group\Plugin\field_group\FieldGroupFormatter, so I guess we'll need to use a different approach or move the logic to a different spot.
Comment #11
chrisolofTurned out that 8.x-3.x deprecated the use of the pre-render callback and moved everything under the #process form callback. The properties we're after here, like '#children_errors', only appear in the pre-render callback.
The attached patch registers a pre-render callback function for forms with fieldgroups and in that callback function opens any fieldgroups that contain elements with errors. This patch is fieldgroup type agnostic and will work with any fieldgroup that sports an "#open" property.
To test in a form, be sure to turn off client-side validation as that's still a work-in-progress (see #2787179: Ensure visibility of invalid fields (JS)). In a form alter hook you can add:
This is ready for review.
Comment #12
daniel kulbeThe patch seems to be applied to the current version.
Comment #13
daniel kulbeSry, was mistaken. This simply cannot be applied to RC1.
Comment #14
kell.mcnaughton commentedhttps://www.drupal.org/files/issues/2020-01-16/field_group-open-groups-w...
Rerolled patch from #11
Comment #15
daniel kulbeRerolled patch from #14
Comment #16
mekal commentedIt seems patch #15 breaks the node/add/ page in drupal 9.0.3 with both field_group 3.1 and 3.1-dev.
This line in the patch seems to be the culprit:
$form['#pre_render'][] = 'field_group_form_pre_render';And here are two issues that might be relevant:
https://www.drupal.org/project/field_group/issues/3109552#comment-13580989
https://www.drupal.org/project/field_group/issues/3147495#comment-13680974
Comment #17
mekal commentedPatch #15 also has an issue on the node create page on 8.9.1 - 8.9.9.
I appears that if a tab has a required field in a tab and the "Mark group as required if it contains required fields." setting is enabled for that tab, then all the fields in that tab will be hidden when you first go to create a new page (node/add/page).
But if you try to submit the form, the fields will appear, along with the required field message(s).
So you can still make it through the process of creating the page, but its definitely not ideal.
See screenshots:
empty-tab-on-page-load.png : The node/add/page form when its first loaded.
empty-tab-after-save.png: And after you hit the save button.
Comment #18
daniel kulbeUpdated the patch for D9 compatibility.
Comment #19
daniel kulbeFixed the undefined function call.
Comment #20
daniel kulbeComment #21
joshua.boltz commentedThis may help someone else, but I also tried things like using latest 3.x-dev as specified in https://www.drupal.org/project/field_group/issues/3109552#comment-13554032, yet the error was still occurring.
It turns out that my codebase was using this patch:
https://www.drupal.org/project/field_group/issues/2894213#comment-13683617
Which that patch adds some of the pre_render logic that is now an issue in D9.
I found the solution to fix this issue was when I stumbled upon:
https://www.drupal.org/project/field_group/issues/2894213#comment-14008160
Which updates that patch to be D9 supported. Basically converts the pre_render callback to an TrustedCallbackInterface instance like the error states.
Comment #22
livnluvnit commentedIve been researching this for about a week now and so far Joshua's step gave me hope but error continues to appear. I am running Drupal 8.9.13
Comment #23
styrbaekThe patch not fixing the issue for me.
Drupal 9.1.6
Comment #24
bohus ulrychI've also spend some time trying to find solution for this error. I'm using Drupal 9.1.9 with patch #20.
My problem was caused by another module - paragraphs, with patch "Field group support broken" https://www.drupal.org/project/paragraphs/issues/3138609. As you can see in the comment #35 https://www.drupal.org/project/paragraphs/issues/3138609#comment-13934356 this patch uses call for field_group_form_pre_render() - and this is problem.
So search in you modules folder for modules calling field_group_form_pre_render() and try to remove it.
Comment #25
mlncn commentedThank you Joshua— as Bohus notes if you this doesn't fix the error look for additional modules/patches using field_group_form_render. Daniel's latest patch does fix the problem here.
In other news this patch is still fixing the original issue to and i think is RTBC.
Comment #27
nils.destoop commentedThx for the patch. I tested it and confirmed to be working.
I modified it a bit, to still have BC support for modules that are using the field_group_form_pre_render instead of the process method. Otherwise field_group would be broken for those modules.