Notice: Undefined index: #attributes in template_preprocess_fieldset()

Created on 8 August 2017, about 7 years ago
Updated 30 January 2023, over 1 year ago

The following happens if you want to render a fieldset without #attributes and without #description and without #id:

Notice: Undefined index: #attributes in template_preprocess_fieldset() (line 217 of core/includes/form.inc).

The strange thing is:

At first, template_preprocess_fieldset() makes an effort to support this case:

function template_preprocess_fieldset(&$variables) {
  [..]
  $variables['attributes'] = isset($element['#attributes']) ? $element['#attributes'] : [];

But then further below, it does not care anymore:

  if (!empty($element['#description'])) {
    $description_id = $element['#attributes']['id'] . '--description';

I would say this is inconsistent. Either make #attributes required or not.

๐Ÿ› Bug report
Status

Needs work

Version

10.1 โœจ

Component
Renderย  โ†’

Last updated 7 days ago

Created by

๐Ÿ‡ฉ๐Ÿ‡ชGermany donquixote

Live updates comments and jobs are added and updated live.
  • Novice

    It would make a good project for someone who is new to the Drupal contribution process. It's preferred over Newbie.

Sign in to follow issues

Merge Requests

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • The Needs Review Queue Bot โ†’ tested this issue. It either no longer applies to Drupal core, or fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    Apart from a re-roll or rebase, this issue may need more work to address feedback in the issue or MR comments. To progress an issue, incorporate this feedback as part of the process of updating the issue. This helps other contributors to know what is outstanding.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom rachel_norfolk UK

    Marking as the patch needs a re-roll if an eager first time contributor at DrupalCon would like to oblige...

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria till79

    I am working in this on Drupal Con Barcelona

  • Merge request !9629rerole patch from the comments 34 โ†’ (Open) created by till79
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria till79
  • Pipeline finished with Failed
    21 days ago
    Total: 159s
    #294072
  • Pipeline finished with Failed
    21 days ago
    Total: 608s
    #294089
  • ๐Ÿ‡ฆ๐Ÿ‡นAustria till79
  • Pipeline finished with Failed
    21 days ago
    Total: 4312s
    #294166
  • Pipeline finished with Failed
    21 days ago
    Total: 3138s
    #294337
  • Pipeline finished with Failed
    21 days ago
    Total: 837s
    #294435
  • First commit to issue fork.
  • Pipeline finished with Canceled
    21 days ago
    Total: 155s
    #294627
  • Pipeline finished with Success
    21 days ago
    Total: 371s
    #294629
  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia abhaisasidharan

    I've reviewed this and also updated the code to add visually-hidden class in the template_preprocess_fieldset().
    I've also tested this and attaching a screenshot that shows the class visually-hidden being added.
    @till79 has added tests for the description being shown and hidden.

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria vierlex

    I have reviewed the MR and can see that an additional a css class 'visually-hidden' will be set for when #description_display is invisible.
    The tests are covering the description and the invisibility feature successfully.

    I also noticed the data attribute 'data-drupal-field-elements' is being added, which doesn't seem to do anything?
    Searching through the gitlab repository on the 11.x branch, there is only one more occurrence https://git.drupalcode.org/project/drupal/-/blob/11.x/core/includes/them...
    Maybe this data attribute can be safely removed? Or does this improve accessibility somehow?

  • ๐Ÿ‡ฆ๐Ÿ‡นAustria vierlex
  • The Needs Review Queue Bot โ†’ tested this issue. It fails the Drupal core commit checks. Therefore, this issue status is now "Needs work".

    This does not mean that the patch necessarily needs to be re-rolled or the MR rebased. Read the Issue Summary, the issue tags and the latest discussion here to determine what needs to be done.

    Consult the Drupal Contributor Guide โ†’ to find step-by-step guides for working with issues.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom rachel_norfolk UK

    Just to keep this nice issue rolling alongโ€ฆ

    When adding tests, it is always worth just looking at the format of all the others as a check youโ€™ve done everything โ€œjust rightโ€. Also, of course, you can run tools like PHPStan (like the bot does) before committing as a way to see what will happen.

    The ultimate irony is that Iโ€™m also quite guilty of occasionally forgetting to add this very return type to my own tests!

    Great work by the whole bunch of contributors at DrupalCon Barcelona to get it to this stage!

  • Pipeline finished with Success
    7 days ago
    Total: 732s
    #307515
Production build 0.71.5 2024