Field group doesn't work with custom entity

Created on 11 March 2017, over 7 years ago
Updated 10 October 2023, 9 months ago

Hello i try field group vesion 8.x.dev with drupal version 8.3 but it doesn't work with custom entity

πŸ› Bug report
Status

Fixed

Version

1.0

Component

User interface

Created by

πŸ‡«πŸ‡·France lazzyvn paris

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡¨πŸ‡΄Colombia jidrone

    After deeper testing I think the issue is related to how the entity theming is being managed.

    There are other issues related like πŸ’¬ Manage form display issue Active and ✨ The order of output of fields before voting Active , I also had an issue using field group module.

    I will start a merge request with an approach than can fix all of them.

  • πŸ‡¦πŸ‡ΊAustralia drasgardian

    For anyone else trying to get field groups to show up on a custom entity display, I found the following. Working within field_layout regions too.

    1. Add to theme registry.
    ```
    /**
    * Implements hook_theme().
    */
    function MY_MODULE_theme($existing, $type, $theme, $path) {
    return [
    'MY_ENTITY' => [
    'render element' => 'elements',
    ],
    ];
    }
    ```

    2. Prepare the entity template variables beneath the 'content' key.
    ```
    function template_preprocess_MY_ENTITY(&$variables) {
    $variables['view_mode'] = $variables['elements']['#view_mode'];

    // Helpful $content variable for templates.
    $variables += ['content' => []];
    foreach (Element::children($variables['elements']) as $key) {
    $variables['content'][$key] = $variables['elements'][$key];
    }

    }

    ```

    3. Add MY-ENTITY.html.twig file to templates
    With at least:
    ```
    {{ content }}
    ```

Production build 0.69.0 2024