Altering data of non-existent field “keeper_machine_name“

Created on 6 October 2021, about 3 years ago
Updated 20 January 2023, almost 2 years ago

When the node_keep_token module is enabled, but the keeper_machine_name field is removed from the form display, you will get an error message on the node add/edit forms.

Notice: Undefined index: #type in Drupal\Core\Form\FormHelper::processStates() (line 211 of core/lib/Drupal/Core/Form/FormHelper.php).

This is because the form alter in node_keep_token_form_node_form_alter is doing changes on the keeper_machine_name field and is adding #states, essentially to something that has incomplete form data. The field isn't present in the form array, so basically the code below is all that exists of the field.

$form['keeper_machine_name']['#group'] = 'node_keep_wrap';
$form['keeper_machine_name']['#states'] = [
  'visible' => [
    [':input[name="node_keeper[value]"]' => [['checked' => TRUE]]],
  ],
];
🐛 Bug report
Status

Fixed

Version

2.1

Component

Code

Created by

🇸🇮Slovenia jzavrl

Live updates comments and jobs are added and updated live.
Sign in to follow issues

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