"Section + h2" field group formatter

Created on 15 July 2024, 7 months ago

Problem/Motivation

For me, one of the most common use cases for field_group is to group content fields in the display area.
A natural html tag would be <section> and <h2> or <h3>

And yet, field_group module does not offer this possibility.
Also, I find no other modules that do it.

It is possible to achieve this with "html element", or with template overrides.
But this leads to a lot of custom code or config per field group, instead of having a simple standardized way to achieve it.

Steps to reproduce

Proposed resolution

Create a field group formatter for "section + heading".
To choose the heading level, either provide settings, or make it a plugin deriver.

On theme level, we could provide an element type, a theme hook, and/or an sdc.

We could provide default styling for margins, or not.
We should consider:

  • A theme will typically want to override the styling and classes, e.g. a theme based on bootstrap might want to add utility classes for the margins, and get rid of all css coming from field_group module.
  • On the other hand, we want an acceptable out of the box experience for websites that don't have dedicated theming or styling for this element.

I would create a new contrib module for this, but I first want to bring it up to field_group queue, to see if there is an interest.

Design goals

Easy to apply the formatter on multiple field groups, without going into settings, assuming that this could become the most commonly used field group formatter.
Easy to override in themes.
Acceptable out of the box experience without theme override.

Open questions

Add this to field_group module, or create a new module instead? Should some of this (element type) even go into core?
Theme hook, render element type, or sdc?
Setting or plugin deriver for the heading level?

Remaining tasks

User interface changes

API changes

Data model changes

Feature request
Status

Active

Version

3.0

Component

Miscellaneous

Created by

🇩🇪Germany donquixote

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

Comments & Activities

Production build 0.71.5 2024