hook_field_widget_multivalue_form_alter() is removed in D10

Created on 15 December 2023, 10 months ago
Updated 1 January 2024, 9 months ago

Problem/Motivation

See the Streamline field widget hooks (3180429) change record : hook_field_widget_multivalue_form_alter() was removed in Drupal 10, in favor of hook_field_widget_complete_form_alter() so form_display_visibility_field_widget_multivalue_form_alter() in form_display_visibility.module is not called anymore. Therefor some (or all?) functionality of this module is not working anymore in Drupal 10.

Steps to reproduce

1. Install Drupal 10+
2. Install Entity Form Display Visibility
3. Add a breakpoint in form_display_visibility_field_widget_multivalue_form_alter() in form_display_visibility.module
The hook is never called.

Proposed resolution

Refactor to use hook_field_widget_complete_form_alter().

Remaining tasks

Testing all possible fields and setting combinations.

User interface changes

None.

API changes

None.

Data model changes

None.

🐛 Bug report
Status

Fixed

Version

2.0

Component

Code

Created by

🇳🇱Netherlands SanderJP

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

Comments & Activities

  • Issue created by @SanderJP
  • 🇳🇱Netherlands SanderJP

    The main difference between hook_field_widget_multivalue_form_alter (D9) and hook_field_widget_complete_form_alter (D10) is in D9 $elements is the widget itself:

    In D10 we get the parent container element $field_widget_complete_form containing the widget:

    The attached patch is assuming this parent container setup is consistent for all fields but I've only tested this on a node entity type. But this patch allows me to use the Visibility Conditions again.

  • Status changed to Fixed 10 months ago
  • 🇪🇸Spain pcambra Asturies

    Many thanks for your contribution! Release tag coming up.

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

Production build 0.71.5 2024