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.
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | field_group-undefined-index-description-display-3053242-11.patch | 2.22 KB | jaydarnell |
| #3 | field_group-fieldset-description_display-support-3053242-8.patch | 2.34 KB | waldomero |
Comments
Comment #2
waldomero commentedComment #3
waldomero commentedComment #4
nils.destoop commentedI 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.
Comment #5
mariaioann commentedThere 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
Comment #6
marco.bUsing 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.
Comment #7
marco.bComment #8
marco.bComment #9
jane_irwinI'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.
Comment #10
berdirThis 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.
Comment #11
jaydarnellPatch from #3 above rerolled for 8.x-3.2 / dev-3.x
Comment #12
swentel commentedClosing 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.