Problem/Motivation

When adding a description in a fieldset group type, a warning is launched: Warning: undefined index #description_display in form.inc line 217.

Repeatable: Always

Steps to repeat:
1. Download and install Module field_group
2. Add a new group or alter some previously created in the form display of an entity
3. Select fieldset as group type
4. Add a description for the group
5. Save the form display
6. Load the entity form
7. See the warnings in the top of the page

Expected Results:
Form loads without any warning

Actual Results:
A warning is showed: Warning: undefined index #description_display in form.inc line 217

Proposed resolution

The #description_display property is mandatory when a fieldset form element is created, but the field_group/src/Plugin/field_group/FieldGroupFormatter/Fieldset.php is not defining it.

I have created a patch that alters these formatter and adds description_display as a form setting property and defines the description_display value as after by default, so the warning is never launched. Also a new description_display select field was added to the group settings form so the user can select between after, before and invisible options to show the description.

Finally in the entity form settings config file, the description_display property is exported in the format settings section of the group.

Comments

waldomero created an issue. See original summary.

waldomero’s picture

Version: 8.x-3.x-dev » 8.x-3.0-beta1
waldomero’s picture

nils.destoop’s picture

Status: Needs review » Closed (cannot reproduce)

I can't reproduce this issue in the latest dev. I also won't add the setting, as drupal core fieldset templates are not listening to the description_display value for fieldsets. They always print them below.

mariaioann’s picture

There is this core issue that seems to handle the problem of core fieldset templates not listening to the description_display value:
#2396145: Option #description_display for form element fieldset is not changing anything

marco.b’s picture

Using core 9.3.0 and field_group 8.x-3.2 I can reproduce this error at content view display (not tested in edit form).
The error message is shown at node display after saving or flushing the render cache.

marco.b’s picture

Status: Closed (cannot reproduce) » Needs work
marco.b’s picture

jane_irwin’s picture

I'm seeing the same issue, also with core 9.3.3 and field_group ^3.1. This patch will no longer apply on either 3.2 or 3.x-dev.

berdir’s picture

This doesn't just fix the notice but also adds a setting to control it.

I added a minimal fix for this to #3278537: D10 compatibility | Declaration of Drupal\field_group\Routing\RouteSubscriber::getSubscribedEvents() must be compatible with Drupal\Core\Routing\RouteSubscriberBase::getSubscribedEvents() by just hardcoding the default description display property as it caused failing tests.

jaydarnell’s picture

Patch from #3 above rerolled for 8.x-3.2 / dev-3.x

swentel’s picture

Status: Needs work » Closed (duplicate)

Closing in favor of #3205504: Add support for #description_display for container types that support it which has more core (e.g. schema etc)

Also committed the minimal fix in #3310222: Branch tests fail on description_display notice and in MigrateUiFieldGroupTest to get the branch tests working again.