actions_top doesn't have #parents

Created on 1 February 2024, 11 months ago

Problem/Motivation

I found that adding actions_top means I can't do $form_state->setErrorByName('') because it triggers a warning, and if I have inline_form_errors module it triggers a whitescreen.

Warning: Undefined array key "#parents" in Drupal\Core\Form\FormState->getError() (line 1137 of core/lib/Drupal/Core/Form/FormState.php).
Drupal\Core\Form\FormState->getError(Array) (Line: 165)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 125)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object, Array) (Line: 125)
Drupal\Core\Form\FormErrorHandler->setElementErrorsFromFormState(Array, Object) (Line: 26)
Drupal\Core\Form\FormErrorHandler->handleFormErrors(Array, Object) (Line: 199)
Drupal\Core\Form\FormValidator->finalizeValidation(Array, Object, 'profile_doi_edit_form') (Line: 119)
Drupal\Core\Form\FormValidator->validateForm('profile_doi_edit_form', Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('profile_doi_edit_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 48)

Steps to reproduce

  • Add workflow actions
  • Choose the option to add action buttons to the top of the form
  • Do a custom form validation
  • $form_state->setErrorByName('', 'Some message');

Proposed resolution

My assumption is that how getElementByName() works, that if an element doesn't get a #parents key then something is not quite right in how the form is being altered.

Remaining tasks

User interface changes

API changes

Data model changes

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇦🇺Australia sime Melbourne

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

Comments & Activities

Production build 0.71.5 2024