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
- Create any Conditional Fields dependency and open the entity form.
- Inspect
ConditionalFieldsFormHelper::getState(). - Confirm
WidgetBase::getWidgetState()is never called and$dependee_form_stateremains 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_infoparameter should remain part of the API. Removing it would be a BC break.
Issue fork conditional_fields-3617716
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
Comment #3
joelpittetMerge train going on this, the test passed with red (tests only)/green