Notice: Undefined index: #name

Created on 20 January 2021, almost 4 years ago
Updated 8 September 2024, 3 months ago

Problem/Motivation

If a form widget contains an element that does not have a #name key (for example, a container), it triggers this notice:

Notice: Undefined index: #name
in ConditionalFieldsFormHelper.php line 192

Steps to reproduce

/**
 * @param $form
 */
function mymodule_form_alter(&$form) {
  $form['field_my_field']['widget'][0]['foo'] = [
    '#type' => 'container',
    'bar' => [],
  ];
}

Proposed resolution

ConditionalFieldsFormHelper::getState() should check if the #name key exists.

Remaining tasks

I will submit a patch.

πŸ› Bug report
Status

Fixed

Version

4.0

Component

Code

Created by

πŸ‡«πŸ‡·France prudloff Lille

Live updates comments and jobs are added and updated live.
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.

Production build 0.71.5 2024