Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Problem/Motivation
It seems like field groups are not compatible with field layout. The groups I created for a display simply disappeared after enabling field layout. Also, if I try to create any new groups, they simply disappear immediately.
Steps for reproducing
- Create a field group for a entity display
- Enable field layouts
- Save entity display using some field layout
- Field groups are gone, kaboom!
Proposed resolution
- Change render and nest logic and use the #group functionality
Comment | File | Size | Author |
---|---|---|---|
#72 | field_group-n2878359-72.patch | 38.56 KB | DamienMcKenna |
#71 | field_group-n2878359-71.patch | 38.39 KB | DamienMcKenna |
Comments
Comment #2
marco.falconi CreditAttribution: marco.falconi commentedI'm having the same issue..
Comment #3
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedThis will need some work, but i'll investigate it. First commit is coming any moment. This will fix an issue when you change layout.
Comment #5
brayfe CreditAttribution: brayfe as a volunteer commentedI am using the 8.x-3.x-dev version of Field_Group and have come across the same issue as the OP. Field Layout version 8.3.2. Enable both Field Layout and Field Group. Edit the structure of a content type. Create a grouping on the "Manage Display" tab of the content type. Choose any layout (2 Column, 3 Column) for the Layout Settings, then move groups into the new layout sections. The groupings don't disappear from the admin form, but are not displayed when viewing the content. The fields are in the correct layout regions, just not grouped or collapsed accordingly.
Comment #6
ricksta CreditAttribution: ricksta commentedConfirmed. The same behavior is happening for me, as mentioned above. I've used Field Group for years. It's been a basic part of my site building kit. Thanks to the developers for all the work they've done so far. I'm hoping this get fixed soon for D8.
Comment #7
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedWIP patch. basic rendering of forms is fixed with this patch. But I still have to run tests and see what gets broken.
Comment #8
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedComment #9
Kris77 CreditAttribution: Kris77 commentedHi @zuuperman, I applied your patch and now it seems to work.
I use Drupal 8.35 with FIELD_LAYOUT installed and FIELD_GROUP 8.x.3.dev. PHP 7.0
Thank you so much.
Comment #10
bserem CreditAttribution: bserem at zehnplus commentedPatch didn't work for me:
Drupal 8.3.5 (composer template)
Field_group 8.x-3.x-dev (commit:83c00b5) with patch from #7
Field_layout enabled.
I assign a simple field group div which never gets displayed.
Comment #11
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedNew patch. This patch is now for both forms as entity displays (i tested on a node). The unit tests are also green.
Comment #12
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedComment #13
webcultist CreditAttribution: webcultist commentedJust tested. With the #11 patch & without, the groups are not visible when a layout ist chosen. :/
Comment #14
webcultist CreditAttribution: webcultist commentedComment #15
_dcre_ CreditAttribution: _dcre_ commented#11 works for me. fieldgroups are now rendering correctly.
However this patch caused paragraphs to stop working.
Whenever i try to add a new paragraph item, i get a (silent) ajax error.
drupal logs show the following
Location: http://myurl/node/add/mycontentype?_wrapper_format=drupal_ajax&ajax_form=1
Message: LogicException: Unable to parse the controller name "field_group_form_pre_render". in Drupal\Core\Controller\ControllerResolver->createController() (line 120 of /mypath/core/lib/Drupal/Core/Controller/ControllerResolver.php).
Comment #16
archnode CreditAttribution: archnode at Signal commentedJust as a small heads up: Modules that provide field group integration like "profile" will crash if the patch is applied (as the field_group_form_pre_render function won't exist anymore).
Comment #17
bryanmws CreditAttribution: bryanmws commentedFollow up issue to have paragraphs supporting this patch: https://www.drupal.org/node/2907094
Comment #18
florianmuellerCHAlso tested with Field Group 8.x-1.0-rc6 and Display Suite 8.x-3.1 - I couldn't even apply patch #11. This is kinda a show stopper right now...
Comment #19
niknakThis patch work fine for me, Thx
Comment #20
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commented@ #18 you need to use fieldgroup 8.3 for drupal core 8.3 and higher.
I'll change the patch to re-add field_group_form_pre_render but mark it as deprecated
Comment #21
freelockGiven that 8.0 - 8.3 are now EOL, and only 8.4 is supported, why do we have an incompatible release tagged as recommended on the module page? Can we get a recommended release of field_group 8.3?
Comment #22
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedbecause you can not recommend a dev release. I wanted more people to test this patch, as the rendering process is changed completely. Even for users without field layout
Comment #23
stevieb CreditAttribution: stevieb commentedI'm geting a lot of the following errors ... while my site uses paragraphs the groups are not in the the my paragraph types
LogicException: Unable to parse the controller name "field_group_form_pre_render". in Drupal\Core\Controller\ControllerResolver->createController() (line 120 of /var/www/html/core/lib/Drupal/Core/Controller/ControllerResolver.php).
Comment #24
AnybodyI can confirm #15, #23 and that this major problem still exists with field_layouts in 8.4.x
Comment #25
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedAll people with fatal errors. That is a known issue. See #17, paragraphs needs an update to support the new patch.
Meanwhile an update patch. The fatal error will be gone then, but no groups will be visible untill the paragraphs module is updated.
Comment #26
afi13 CreditAttribution: afi13 commentedComment #27
Alan D. CreditAttribution: Alan D. commentedConfused about patch #25, it's attempting to add a function that already exists:
http://cgit.drupalcode.org/field_group/tree/field_group.module?h=8.x-3.x
I've got the groups showing without this patch, but I can not comment regarding the Paragraph issues people were noting.
Comment #28
Alan D. CreditAttribution: Alan D. commentedQuick followup
This was my custom FG plugin for 1.x that was rendering fine in 1.x. It shows the first non-empty field assigned to the group and hides the rest.
In 3.x, the element array is not populated with the actual fields (array keys are set with NULL values), so it's impossible to interact with the fields. And the $element array is not being rendered, though it's child elements are.
So patch in #25 is outdated and I believe there appears to be an major issue in field_group_fields_nest() that can't find the field to populate the element before the pre-render.
To replicate using 8.x-3.0-beta1, add any group when using field layouts and add some fields to it. The group isn't rendered, but the fields are.
So from my limited testing, the field groups in the display admin pages seem ok, but when viewing these displays, the groups aren't being rendered correctly
Comment #29
chOP CreditAttribution: chOP at Deloitte Digital commentedPatch 11 works, but throws a warning notice when used with PHP 7.1
Warning: Parameter 1 to field_group_form_process() expected to be a reference, value given
This amends patch #11 to address the warning notice.
Comment #30
oriol_e9gSame problem and seems that #29 works.
Comment #31
Alan D. CreditAttribution: Alan D. commentedSwitched over to use Field Layouts so no longer able to review the real patch myself again :)
Comment #32
Fernly CreditAttribution: Fernly at District09 commentedI can confirm the patch is not working:
The field groups don't disappear but they are rendered outside of the field layout markup.
Comment #33
cameron prince CreditAttribution: cameron prince commentedHere's a re-roll of #11 and #29 along with a fix for the issue with the field groups rendering incorrectly on the entity edit form.
There is still one obscure problem I'm having trouble resolving. If you enable a field layout on the default display tab and try to add a field group there is an Notice: Undefined index: name in Drupal\field_ui\Element\FieldUiTable::reduceOrder() (line 236 of core/modules/field_ui/src/Element/FieldUiTable.php). error. Dragging and arranging the field group works, but when you save, the field group isn't staying where you place it and the error displays again.
If you "Show row weights" and place the field group using the selectors, it saves and works properly.
Comment #34
DamienMcKennaComment #35
AnybodyThank you very much for your great work.
Sadly it kills our paragraphs when clicking "Edit" on a paragraph:Unable to parse the controller name "field_group_form_pre_render". in Drupal\Core\Controller\ControllerResolver->createController() (line 120 of core/lib/Drupal/Core/Controller/ControllerResolver.php). Drupal\Core\Controller\ControllerResolver->getControllerFromDefinition('field_group_form_pre_render') (Line: 376)
Any ideas where to start? I'm willing to debug this with you.EDIT: My mistake! I also had to apply patch "Fix support for field_group module in combination with field_layout module patch (#2907094: Make paragraphs module working with field_group version 3.x with support for the field_layout module)": "https://www.drupal.org/files/issues/2907094_7_field_group_support.patch"
Now IT WORKS!! Hooray! :) Thank you so much!
My last problem / notice is:
Notice: Undefined index: #group_name in field_group_theme_suggestions_alter() (Zeile 89 in /var/www/vhosts/web10.v1750.ncsrv.de/httpdocs/preview/ife-owl.de.preview.webks.de/modules/contrib/field_group/field_group.module). array(57)
When I edit a paragraph.
But I think we can set this "needs review" again. How can we make sure that #2907094: Make paragraphs module working with field_group version 3.x with support for the field_layout module will be included in paragraphs when this patch is RTBC?
Comment #36
cameron prince CreditAttribution: cameron prince commentedA user ran into a bug with the patch in #33. I neglected to consider cases where a field group wouldn't have a region, i.e. no field layout. Here's an updated patch with a fix.
Comment #37
DamienMcKennaComment #38
AnybodyI just tested the patch from #36 manually in our i18n environment and it still works great. RTBC+1 Please review.
Comment #39
askibinski CreditAttribution: askibinski as a volunteer and at ezCompany commentedPatch applies but there is an issue with fieldsets in combination with a paragraph + inline entity form.
I am using the paragraphs patch in 2907094.
Reproduce:
* create an entity (in my case a custom entity but another node should also do) with some horizontal tabs
* create an inline entity reference in another node to this entity using a paragraph
* edit node and edit inline
form displays used:
- using paragraphs "experimental" form display
- using "Enline entity form - complex" form display
Expected: tabs
Result: all fields shown without field groups
Note: when editing the entity directly tabs do appear, so it seems to be an issue with inline entity form. Not sure if the the patch should also be for inline_entity_form though.
Update, did some debugging: it seems $element['#fieldgroups'] is empty in field_group_build_entity_groups for my inline entity.
However, they are added in field_group_attach_groups() for the entity.
Comment #40
DamienMcKennaI think some test coverage improvements would greatly help here.
Comment #41
DamienMcKennaComment #42
jwilson3Cross post from #2907094-13: Make paragraphs module working with field_group version 3.x with support for the field_layout module here, because this might be a fundamental issue with this patch and not the paragraphs patch:
Tested with patch in comment #36 and #33 with the Paragraphs patch and in both cases, while the error messages are gone, field groups inside the Paragraph type disappear. If I make the paragraph field 'required' and configure the paragraph widget to auto-create the first instance, then the field groups appear outside the paragraph field straight on the main node creation form on /node/add/page.
I should also point out that without either the patch from this issue nor the patch from #2907094 the field groups on the paragraph type works perfectly fine even with Field Layout module enabled, but breaks when you add a field group to the node itself. It seems like there is something fundamentally wrong with node rendering, and I might suggest looking at an alternate solution (if it exists) that doesn't completely get rid of field_group_form_pre_render since that seems to be working for a number of modules already that depend on it (paragraphs, profile).
Comment #43
DamienMcKennaThanks for the extra eyes, jwilson3.
I'm going to again suggest someone work on improving the test coverage, it'd greatly help.
Comment #44
AnybodyI can confirm the statement from #42. We're having the same results in our manual tests with the patches. Currently with both patches applied the fieldgroups disappear in paragraphs, which is worse than with no patch. I'd like to help but my knowledge about the things behind this issue is by far too low to provide anything than feedback from my manual tests so far.
Comment #45
AnybodyNew information: We now uninstalled field_layout in a project where the field groups were positioned wrong (weight had no effect in commerce product display) but it didn't change anything. The position is still wrong without field_layout.
were using field_group 8.x-1.x-dev without patches there. So perhaps not all problems in this issue are really related to field_layout?
For example this #2942234: Does not work with commerce or other entities without a "content" render array key seems to be the problem in this case.
Comment #46
steveoriolIssue still here with D8.5.0... :-(
One solution at the moment is to use the module "Display Suite" instead, but this does not works for the "form display" only for "display"...
Comment #47
jwilson3^^ thanks for pointing to #2942234, where there's a comment:
So perhaps (?) there is some collision between
content
and the painfully annoyingcontent._field_layout.content
that gets injected into Twig templates when Field Layout is enabled (using the "one column" default layout). Just a random guess, no time to investigate more deeply at the moment.Comment #48
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedAn updated patch. Note, I see people all still using outdated patches. The work for this patch lives in a separate branch: https://cgit.drupalcode.org/field_group/log/?h=field-layout-support
First tests on my side indicate that fieldgroups is working again for:
- node edit form without paragraph
- node edit form with fieldgroups in a paragraph
- node view
- node view with fieldgroups in a paragraph
- node view with field layout
- node view with field layout and fieldgroups in the paragraph
Note: The patch of https://www.drupal.org/comment/12472238#comment-12472238 is still needed.
Comment #49
Anybody@zuuperman: Thank you so much!! I'll now try patch #48 from here + #7 from https://www.drupal.org/project/paragraphs/issues/2907094
The patch from #48 is against 8.x-3.x-dev correct?
The ALTERNATIVE would be to use branch "field-layout-support" am I right? Or is #48 against that branch?
Comment #51
AnybodyI can confirm what CI says: The patch can not be applied against 8.x-3.x-dev
Comment #52
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedCorrect. Patch was broken due to some commits on dev yesterday. Included a new diff of the field layout branch.
Comment #54
AnybodyPatch applies cleanly now. We'll test the result and report back in the next days. Thank you very very very much for your hard work on it!
Comment #55
oriol_e9gThere is a PHP error here, missing the final ]:
Comment #56
AnybodyI can confirm #55, could you create a new patch perhaps, zuuperman?
Comment #57
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedDamn, the last 8.3.x commit was not in field layout branch, leading to the ] issue. Included updated patch
Comment #58
AnybodyThank you very very much! I can confirm that the patch (with manually corrected ]) works GREAT! :)
Comment #59
DamienMcKennaJust to let the maintainers know - if you create a branch that starts with an issue number it'll automatically show up in that issue's sidebar; see #2679132: Add UI for feature branches for details.
Comment #61
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedThx for letting me known. I renamed the branch :)
Comment #62
AnybodyI can finally confirm that the patch from #57 solves all problems and also works perfectly in paragraphs combined with #7 from #2907094: Make paragraphs module working with field_group version 3.x with support for the field_layout module!
So shell we set this issue RTBC? The paragraphs issue should be RTBC'd and commited when the new branch or patch from #75 is being merged + commited in field_group. Perhaps leave a notice over there or contact the paragraphs maintainer before release?
Comment #63
AnybodyComment #64
jhedstromFor folks experiencing the php notice
Notice: Undefined index: name in Drupal\field_ui\Element\FieldUiTable::reduceOrder() (line 236 of core/modules/field_ui/src/Element/FieldUiTable.php)
it is actually unrelated to this issue, and more related to old configs that pre-date core's move to specifying
region
in entity displays. I've opened #2968184: The region part of entity view config isn't set for old installs, which adds an update hook to set this for old configs.Comment #65
DuaelFrThanks all that worked on that patch before me :)
I needed a way to install this version through composer so I made a new patch that applies on 8.x-3.x including some minor cleanups.
Given the state of the
2878359-field-layout-support
branch I strongly suggest that this patch is applied directly on 8.x3.x instead of merging the branches. The attached interdiff show the diff between my patch and the current state of the branch.Comment #66
joelpittet@DuaelFr thank you this makes field layout work!
Comment #67
joelpittetReviewing the code it looks like there is a few coding standard issues but there are some in the module itself so something for a cleanup maybe with
phpcbf
?https://www.drupal.org/node/1587138
Comment #68
DuaelFrDo you suggest to fix all coding standards or just those in the patch?
Comment #69
joelpittetSorry, I can see how my message can get confused.
Only fix coding standards within the patch but if they are not fixed here, it would be worth running code sniffer shortly before or after the next release(to minimize patch disruptive rerolls in the queue).
Comment #70
Buzzbee CreditAttribution: Buzzbee commentedI successfully use Field Group in a Drupal 7 installation. It works great. However, due to this incompatibility with field layout (which we use for other styling), I cannot get it to work with Drupal 8.5.4. It just simply does not do anything. Not even the group's div name appears in the html source code! We may be able to use the patch but following your last comments, the code of the patch is not clean. Thus we are hesitant to even try it. Is there a roadmap for the next release which includes this patch? Thanks in advance!
Comment #71
DamienMcKennaRerolled.
Comment #72
DamienMcKennaThis patch includes the one line fix from #2955526: Error: Call to a member function preRender() on null in field_group_field_group_pre_render() because the line endings being incorrect makes it hard to apply patches via composer.
Comment #74
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedComment #75
Anybody@zuuperman, thank you very very much!! This is one of the most important commits in the last month I think :) There will be many happy faces once the stable is released.
Comment #76
nils.destoop CreditAttribution: nils.destoop as a volunteer and at Wunder commentedStrange. Seems my comment wasn't posted. But thx for the reviewing, everything is now committed to dev :)
Comment #77
miro_dietikerAwesome! But so much refactoring without a single line of tests updated / added. Thus it's even harder for me to understand the impact.
Status "Fixed" and tag "Needs tests" seems a bit inconsistent. What's the general rule about test coverage in field_group?
We need to know more details to decide about how we integrate Paragraphs.
#2907094: Make paragraphs module working with field_group version 3.x with support for the field_layout module
Comment #79
damondt CreditAttribution: damondt commentedThis commit appears to have caused this issue.
Comment #80
weseze CreditAttribution: weseze as a volunteer commentedWhen can we expect this to be in a release?
Besides from paragraphs, paragaphs asymetric translation widgets also suffers: https://www.drupal.org/project/paragraphs_asymmetric_translation_widgets...
Comment #81
No Sssweat CreditAttribution: No Sssweat commentedTried applying the patch in #72 with composer update (added it to composer.json) with both stable and latest dev, both failed to apply...
When applying the patch via PHPStorm (my IDE), it causes errors in Drupal.
Is it just me? Can someone confirm that this patch still works?
Comment #82
AnybodyNo, this is closed / fixed. The patch has already been committed. You don't need it anymore if you use the dev version.
Comment #83
ocastle CreditAttribution: ocastle at Full Bundle commentedI'm also seeing the same issue as #81.
Neither 3.0@rc2 or 3.x-dev versions of the module seem compatible with Drupal 8.8.1 field layout module.
Can anyone else confirm field_group is or isn't working with the latest version of field layout?
Comment #84
komejo CreditAttribution: komejo at ThinkShout commentedUsing field_group 3.0.0-rc2 with Drupal core 8.8.0 and trying to add a field group to a custom entity results inFatal error: Cannot redeclare Drupal\field_group\FieldGroupFormatterBase::process() in /web/modules/contrib/field_group/src/FieldGroupFormatterBase.php on line 233
Update: attempt to patch 3.0.0-rc2 caused 'public function process()' to be applied twice, event though the patch showed as failed.
Comment #85
nils.destoop CreditAttribution: nils.destoop as a volunteer and commentedThe patch will not apply because this code is already committed to dev. The support should now be fixed again in dev, as we fixed #3095570: after update to 3.0-rc2 field groups are not showing (with field_layout module) last week