Problem/Motivation

ConditionalFieldsFormHelper::getState() checks $this->form_state, but afterBuild() sets $this->formState.

Because the undefined property is checked with isset(), the failure is silent. WidgetBase::getWidgetState() is never called and states handlers always receive NULL for $field_info.

No shipped handler currently uses $field_info, so this is not currently user-facing. However, the handler API expects widget state there, and third-party handlers may rely on it.

This was introduced when $form_state was renamed to $formState in #3423942 and this use was missed. It was found while triaging #3499371, but is not the cause of that issue.

Steps to reproduce

  1. Create any Conditional Fields dependency and open the entity form.
  2. Inspect ConditionalFieldsFormHelper::getState().
  3. Confirm WidgetBase::getWidgetState() is never called and $dependee_form_state remains NULL.

Proposed resolution

Replace $this->form_state with $this->formState in getState() so handlers receive the widget state as intended.

Remaining tasks

  • Fix the incorrect property name.
  • Run the FunctionalJavascript handler coverage to catch any behaviour changes now that handlers receive real widget state.
  • Add regression coverage for passing widget state to handlers.
  • Consider separately whether the unused $field_info parameter should remain part of the API. Removing it would be a BC break.
Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joelpittet created an issue. See original summary.

joelpittet’s picture

Status: Active » Fixed

Merge train going on this, the test passed with red (tests only)/green

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.