Check if it is possible to use #theme_wrappers property for field wrapper instead of custom wrapper

Created on 5 October 2023, about 1 year ago
Updated 12 October 2023, about 1 year ago

Problem/Motivation

At the moment the field theme wrapper is added in frontend_editing_entity_view_alter. Check if it is possible to use #theme_wrappers property of rendered array instead.

Feature request
Status

Fixed

Version

1.0

Component

Code

Created by

🇩🇪Germany a.dmitriiev

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

Comments & Activities

  • Issue created by @a.dmitriiev
  • 🇩🇪Germany guido_s Cologne

    This wrapper is a huge problem for me too.
    It actually breaks my site as it changes the structure of the variables in twig and adds a new layer to them.
    That way I can't access field contents in twig anymore.

    The structure should really stay the same for logged in and logged out users.

    Some simplified code example:

    {% for key, item in content.field_accordion_section|filter((value, key) => key|first != '#') %}
        {{ item['#paragraph'].field_accordion_section_title.value }}
    {% endfor %}
    

    If logged out, everything is fine.
    But if I'm logged in, the site is broken as item['#paragraph'] isn't available anymore because the structure of item changed completely due to the added depth / wrapper.
    I still want to use frontend editing on this field, so disabling it in the settings is not an option for me.
    But with the current wrapper implementation this module is of no use to me as it breaks everything.

  • 🇩🇪Germany a.dmitriiev

    Guido_S, the setting for disabling the field is exactly to remove this field wrapper that prevents you from accessing the data in the template. It will not disable frontend editing. Field wrapper is only to have update of the content without page reload. If you are ok with reload of the page every time you change the content (how it was in the previous version), you can disable this field wrapper completely. The module will still work, but there will be no smooth content update without page reload, but instead the page will reload (again, how it was in the previous version).

    You can disable ajax reload completely on this page /admin/config/frontend-editing/ui-settings. Or just disable ajax (not the complete module) for specific field where you have sensitive twig file.

    I am changing this back to "Feature request".

  • 🇩🇪Germany guido_s Cologne

    Thanks for the info, a.dmitriiev!
    Then those settings should get a better description as it currently says:

    List of fields to exclude from the frontend editing. One field per line. Format: entity_type.bundle.field_name

    And nothing about just removing the wrapper and disabling ajax updating for this field.

  • 🇩🇪Germany a.dmitriiev

    Yes, it seems that the description is unclear, sorry for that. I will try to re-phrase it, so it is more accurate and does not confuse users.

  • @admitriiev opened merge request.
    • a.dmitriiev committed 4caaec6a on 1.x
      Issue #3391887: Check if it is possible to use #theme_wrappers property...
  • Status changed to Fixed about 1 year ago
  • 🇩🇪Germany a.dmitriiev

    #theme_wrappers worked like a charm. There are no more extra elements, so it should be possible to access the properties inside field render array like it was before and still have the "Ajax content update" enabled.

  • Automatically closed - issue fixed for 2 weeks with no activity.

Production build 0.71.5 2024