[plan] Add layouts to entity displays (both form and view)

Created on 6 September 2016, almost 8 years ago
Updated 20 October 2023, 8 months ago

Problem/Motivation

The Field UI allows the rearranging of fields for a given piece of content, both for the authoring form and for the content display.
Each type of content can have multiple "view modes" (full, teaser, etc.), each which can have their own arrangement of fields. There is no concept of regions or sections, the fields can only be ordered.

In the contributed module space, modules like Panelizer and Display Suite enhance the display of content by adding support for layout, alongside many other functional improvements.

Also currently a contributed module, Layout Plugin is a module that drives the Layout mechanism of the above modules, but has no UI of it's own. It simply discovers and exposes layouts as an API.

Proposed resolution

Add the ability to choose a layout for each view mode, within Field UI.

Because entity displays are used for forms, this will allow site builders to customize the layout of the authoring form. Fields can be shown or hidden, and rearranged into any chosen layout. Each type of content can have multiple "form modes", each with a layout.

Entity displays also control the rendering of content. Different "view modes" are used when content is displayed in different places: shown as a paged list of teasers, when displayed in a sidebar as a bulleted list of titles, when shown as a canonical representation on its own page, etc.
These too can each have their own layout, with fields rearranged and toggled as necessary.

The first iteration will begin by hardcoding a few example layouts (one with top/bottom, one with left/right).

Proposal roadmap

Must-have

Should-have

Could-have

  • #2820210: Add Settings Tray support to field_layout β†’
  • #2846395: Increase module weight of field_layout β†’
  • Per-entity overrides
  • Front-end UI to change layouts (determined to only be desired after per-entity overrides lands
  • Explicit followup issue added to the @todo for:
    +++ b/core/modules/field_layout/src/Entity/FieldLayoutEntityViewDisplay.php
    @@ -0,0 +1,24 @@
    +  public function getDefaultRegion() {
    +    // This cannot be provided by the trait due to
    +    // https://bugs.php.net/bug.php?id=71414 which is fixed in PHP 7.0.6.
    +    return $this->getLayoutDefinition($this->getLayoutId())->getDefaultRegion();
    

    and similar in core/modules/field_layout/src/Entity/FieldLayoutEntityFormDisplay.php.

  • Full integration with Context system to allow Panels-esque placement of other non-field content (block placement in Field UI?!)

Not in scope

Remaining tasks

Create child issues

🌱 Plan
Status

Active

Component

Active Initiative

Created by

πŸ‡ΊπŸ‡ΈUnited States tim.plunkett Philadelphia

Live updates comments and jobs are added and updated live.
  • Blocks-Layouts

    Blocks and Layouts Initiative. See the #2811175 Add layouts to Drupal issue.

  • Needs framework manager review

    It is used to alert the framework manager core committer(s) that an issue significantly impacts (or has the potential to impact) multiple subsystems or represents a significant change or addition in architecture or public APIs, and their signoff is needed (see the governance policy draft for more information). If an issue significantly impacts only one subsystem, use Needs subsystem maintainer review instead, and make sure the issue component is set to the correct subsystem.

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.

  • Is this idea still relevant/active?

    My understanding is that field_layout is not needed anymore because layout_builder now provides the expected functionalities.

    Shouldn't we mark this idea as Closed (won't fix) and remove it from this list β†’ ?

  • πŸ‡¬πŸ‡§United Kingdom catch

    @matthieuscarset layout builder can be configured for view modes, but not for form modes - this is still only handled in core by field_layout. see πŸ“Œ [META] Enable layout builder for form displays, and deprecate field_layout Postponed

  • πŸ‡©πŸ‡ͺGermany donquixote

    I don't like layout builder as a universal replacement for traditional entity displays.
    It seems to me that it targets a specific type of user that does not really exist in the projects I work with.
    But perhaps I don't see the full picture.

    Having field_layout in core is nice, but it being experimental may scare people (including me) from using in production.

    The field_layout module (similar to display suite) is also limited in that it only allows one layout per view mode.
    An alternative would be to insert layouts into a display, similar to field groups.
    Doing this in contrib is always going to be messy. But in core it could work.

    We could also make it easier to insert other dynamic elements into a display.

Production build 0.69.0 2024