Error when field_groups nesting only.

Created on 13 June 2025, about 2 months ago

Motivation

TypeError: reset(): Argument #1 ($array) must be of type array, string given in reset() (line 162 of modules/contrib/ui_patterns/src/Element/Pattern.php).
Drupal\ui_patterns\Element\Pattern::processMultipleSources()

Steps to reproduce

Set a display with Pattern A that renders only a child field_group Pattern B. No fields in Pattern A, only in Pattern B.

  • [field_group] Pattern A
    • [field_group] Pattern B
      • [field] field_b1
      • [field] field_b2

Proposed resolution

No output if no fields. Let the rendering responsability to the child field_group.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇫🇷France Julien Tekrane

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

Merge Requests

Comments & Activities

  • Issue created by @Julien Tekrane
  • Pipeline finished with Success
    about 2 months ago
    Total: 307s
    #521959
  • Pipeline finished with Success
    about 2 months ago
    Total: 200s
    #521981
    • duaelfr committed d2ceaaeb on 8.x-1.x
      Issue #3530141: pattern_formatter field groups should carry basic...
  • 🇫🇷France duaelfr Montpellier, France

    @julien tekrane:
    Hi!
    Thank you for bringing this back. I recognize a big part of your code as my own code from an old PR on github.
    I have been using this for a very long time but it seem that it is not needed anymore to get nested groups working.
    I removed this patch on all my projects without any difference. I guess that's because some "recent" changes in Field Group.

    I just pushed a tiny change in our field group formatter to ensure that field_group_remove_empty_display_groups() has what it needs to handle our groups. That should fix the last use cases with nested groups.

    Do you still have issues? Can you provide steps to reproduce on a clean install?

  • Pipeline finished with Success
    about 2 months ago
    Total: 236s
    #524556
  • Pipeline finished with Canceled
    about 2 months ago
    Total: 88s
    #524559
  • Pipeline finished with Success
    about 2 months ago
    Total: 219s
    #524560
  • 🇫🇷France Julien Tekrane

    @duaelfr

    I updated with 8.x-1.13 version and still have the issue.

    Here is my use case (each point is a pattern) :

    • field_group using pattern "Accordion"
      • field_group using pattern "Accordion item"
        • field_group using pattern "Description list"
          • field Body

    I certainly too much played with _items in my theme/templates/patterns/accordion/pattern-accordion--field-group.html.twig but have no other choice for providing by default

          {%- if _items['#fields'] is not empty -%}
            {% set _items = _items|merge({
                '#fields': _items['#fields']|merge({
                  'status': _items['#fields']['status']|default(_status),
                  'content': _items['#fields']['content']|default(''),
                  'idparent': _id,
                  'is_copyable': _is_copyable,
                  'item_id': _items['#fields']['id']|default(_id ~ '-' ~ loop.index),
                  'loop_index': loop.index,
                  'open_item': _open_item_id == loop.index,
                  'stay_open': stay_open,
                  'title': _items['#fields']['title'],
                  'title_tag': _items['#fields']['title_tag']|default('h2')
                })
            }) %}
          {%- endif -%}

    I have reverted previous commit and suggest a simpler approach. Please review it. Thanks

  • 🇫🇷France duaelfr Montpellier, France

    @julien tekrane Would you provide me your patterns in an attached zip file so I can try to reproduce locally?

Production build 0.71.5 2024