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.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

julien tekrane created an issue. See original summary.

julien tekrane’s picture

Status: Active » Needs review
pdureau’s picture

Assigned: Unassigned » duaelfr

  • duaelfr committed d2ceaaeb on 8.x-1.x
    Issue #3530141: pattern_formatter field groups should carry basic...
duaelfr’s picture

Assigned: duaelfr » Unassigned
Status: Needs review » Postponed (maintainer needs more info)

@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?

julien tekrane’s picture

Issue summary: View changes

@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

duaelfr’s picture

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

duaelfr’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

Spring cleanup!
Feel free to reopen if needed ;)

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.