Adding a field group (a simple div) in a Commerce Product Variation entity type "manage display" tab appears to work correctly and other fields can be nested, but there is no wrapper html output when viewing the rendered entity as part of a Commerce Product.

Using "default" view mode, Stark theme. The Commerce Product uses "rendered entity" to display the referenced Commerce Product Variations, not "add to cart form", so it's a pretty simple entityreference scenario.

A cache flush does not fix it.

Additionally, setting the div to "collapsible" results in an error when displaying the Commerce Product with the rendered Commerce Product Variation entity:

Notice: Indirect modification of overloaded element of Drupal\Core\Template\Attribute has no effect in Drupal\field_group\Element\HtmlElement::processHtmlElement() (line 49 of modules/contrib/field_group/src/Element/HtmlElement.php).
Drupal\field_group\Element\HtmlElement::processHtmlElement(Array, Object) (Line: 75)
Drupal\field_group\Plugin\field_group\FieldGroupFormatter\HtmlElement->preRender(Array, Array) (Line: 286)
field_group_field_group_pre_render(Array, Object, Array) (Line: 526)
field_group_pre_render(Array, Object, Array) (Line: 494)
field_group_fields_nest(Array, Array) (Line: 386)
field_group_build_entity_groups(Array, 'commerce_product_variation', Array) (Line: 287)
Drupal\Core\Theme\ThemeManager->render('commerce_product_variation', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 90)
__TwigTemplate_fdce0be70f9fdfb78bc2c9a3608ef43feef61491d29b11a99f485a5628944977->doDisplay(Array, Array) (Line: 432)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template->display(Array) (Line: 411)
Twig_Template->render(Array) (Line: 64)
twig_render_template('modules/contrib/fences/field.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('field', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array) (Line: 448)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array) (Line: 474)
Drupal\Core\Template\TwigExtension->escapeFilter(Object, Array, 'html', NULL, 1) (Line: 47)
__TwigTemplate_c1833ffc648b3b539e9bf620ed7842baa7837169f99c5fb9a6fa7268640aa7f0->doDisplay(Array, Array) (Line: 432)
Twig_Template->displayWithErrorHandling(Array, Array) (Line: 403)
Twig_Template->display(Array) (Line: 411)
Twig_Template->render(Array) (Line: 64)
twig_render_template('modules/contrib/commerce/modules/product/templates/commerce-product.html.twig', Array) (Line: 384)
Drupal\Core\Theme\ThemeManager->render('commerce_product', Array) (Line: 435)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 195)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 226)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 574)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 227)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 117)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch('kernel.view', Object) (Line: 149)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 64)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 57)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 99)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 78)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 47)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 50)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 23)
Stack\StackedHttpKernel->handle(Object, 1, 1) (Line: 652)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)

Comments

John Pitcairn created an issue. See original summary.

judapriest’s picture

Bug sucessfully reproduce.
Using :
- Drupal 8.2.2
- field_group 8.x-1.0-rc4
- 2 content type : Article & basic page
- Article is "entity referenced" within basic page
- In basic page "manage display", 1 group in "htlm element : div"

When the field "entity reference article" is drag to the group and is alone the group, the content article disappear.
When adding another field the group, the content appear.

And I can confirm all the other symtom reported by OP.

Updated :
Then I updated to field_group to 8.x-1.0-rc6 and everything seems to be repaired.

John Pitcairn’s picture

This does not really reproduce or fix my problem. The commerce_product_variation is a non-node entity referenced by another non-node entity (commerce_product). No matter how many fields are in the group it does not appear. I am using 8.x-1.0rc6.

John Pitcairn’s picture

The problem appears to be that the commerce_product_variation entity does not use an $entity->content property, it uses $entity->product_variation.

This is a similar case to User profiles, which are specifically handled by Field Group module.

It's perhaps not desirable to start special-case handling for every entity type that doesn't use a content element. Is there a standard technique to get the entity property that contains the renderable entity content?

John Pitcairn’s picture

Status: Active » Closed (duplicate)
Related issues: +#2842280: Allow contrib to add support for any entity type

Followup: my patch from #2842280: Allow contrib to add support for any entity type is now committed to dev, so entity modules can add fieldgroup support themselves, or other modules can add support on their behalf, by implementing hook_field_group_content_element_keys_alter() to supply the appropriate content element key for the entity.

Closing this as a duplicate of that.

bolaghi’s picture