Problem
We defined some custom entities which's template function do not always use "elements" as render array.
When I add a field group, for example a html element, the fields are not grouped within the configured element in the frontend markup.
Proposed resolution
Do not rely on "elements", read the configuration of the entity.
Workaround
We switched the render array key all back to "elements". That helps for now.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | render-array-key-check-2557877-4.patch | 682 bytes | danielbeeke |
Comments
Comment #2
axe312 commentedIt also looks like 'content' as render variable is also required to be used that field group works. Is this the normal pattern and all entities should use 'elements' & 'content'?
Comment #3
danielbeeke commentedWe have this same issue while using Display Suite.
Changing the start of the function like this:
Fixed our problem on the front end.
Comment #4
danielbeeke commentedThat is difficult if we don't change a lot of things. The function itself does not know what entity is used without going through the render array. I mean $vars['content']['#entity_type']. Is it acceptable to just check what render array key is used?
Comment #5
jpamental commentedHey @danielbeeke -
I'm experiencing the same issue with Display Suite and tried your code (looks like starting on line 286 in field_group.module) but it didn't do a thing. Still no wrapping element (trying to wrap with a div). If I disable the DS layout I get the wrapping class, but then lose DS Extras ability to customize the field markup. Am I missing something from your solution?
Any tips would be most welcome, and I'm happy to reroll as a patch and post back if I can get it working!
Comment #6
danielbeeke commented@jpamental
Have you tried using the dev version of display suite? Have you applied the patch? The patch is better than the code above. It is missing a variable.
Comment #7
jpamental commented@danielbeeke
So I tried again with the dev version of DS (Pretty sure that's what I had, but downloaded again anyway), and installed the patch to the file_group module but no difference: if I have 'one column layout' selected I get the 'expert' field formatting options (from DS Extras) but no wrapping div. If I set the custom layout back to 'none', I get the wrapper but no expert layout options for fields.
Any ideas? I'm not quite sure what to try next. It seems like neither 'elements' or 'content' is the right var to target (or at least it's not targeting it in the right way?)
Thanks,
Jason
Comment #8
bceyssensAspilicious and I are working on DS today. We just tested #2604994: Field group compatibility combined with #2611758: Field UI table is broken for nested elements and patch #4, and it seems to work just fine!
Comment #9
jpamental commented@bceyssens @danielbeeke -
I can confirm as well that when you combine all 3 patches (one for DS, one for Field Group and one core) it is indeed working as it should be!
Thanks!
Comment #10
nils.destoop commentedThx for researching this. I tested and committed the patch.
Comment #13
aspilicious commented