Problem/Motivation

ContentEntityForm::form() adds the advanced vertical tabs element only when showRevisionUi() returns TRUE. For an entity type that is not revisionable, or has no show_revision_ui, the element does not exist. A field or widget with '#group' = 'advanced' then has no effect.

The condition was added in #2669802 together with showRevisionUi(). #2916809 describes the same effect for the path widget and handles it in PathWidget by wrapping the field only when the advanced group exists.

Steps to reproduce

  1. Define a content entity type that is not revisionable, with a form class that extends ContentEntityForm.
  2. Add a field or widget that sets '#group' => 'advanced'.
  3. Open the entity form.

Result: $form['advanced'] is not set. The element is rendered outside any vertical tab.

Proposed resolution

Create the advanced element in ContentEntityForm::form() regardless of showRevisionUi():

// Advanced tab must be the first, because other fields rely on that.
if (!isset($form['advanced'])) {
  $form['advanced'] = [
    '#type' => 'vertical_tabs',
    '#weight' => 99,
  ];
}

The revision fields are still added only when showRevisionUi() returns TRUE.

ContentEntityFormAdvancedTest builds the form for entity_test, which is not revisionable, and asserts that $form['advanced']['#type'] is vertical_tabs. It fails without the change with Undefined array key "advanced".

Issue fork drupal-3630844

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

maks oleksyuk created an issue. See original summary.

maks oleksyuk’s picture

Status: Active » Needs review