Change record status: 
Project: 
Introduced in branch: 
9.2.x
Introduced in version: 
9.2.0
Description: 

The new field widget hook hook_field_widget_complete_form_alter (hook_field_widget_complete_WIDGET_TYPE_form_alter) was introduced to make it possible to alter the whole widget form after it was proccessed.

In favor of this new hook, hook_field_widget_multivalue_form_alter (hook_field_widget_multivalue_WIDGET_TYPE_form_alter) were marked as deprecated and will be removed in Drupal 10.

Before:

function MYMODULE_field_widget_multivalue_form_alter(&$elements, FormStateInterface $form_state, $context) {

After:

function MYMODULE_field_widget_complete_form_alter(&$field_widget_complete_form, FormStateInterface $form_state, $context) {
  $elements = &$field_widget_complete_form['widget'];

Also hook_field_widget_form_alter (hook_field_widget_WIDGET_TYPE_form_alter) was marked as deprecated and will be replaced by hook_field_widget_single_element_form_alter (hook_field_widget_single_element_WIDGET_TYPE_form_alter).

Impacts: 
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done

Comments

yas’s picture

hook_field_widget_multiple_form_alter(hook_field_widget_multiple_WIDGET_TYPE_form_alter) should be hook_field_widget_multivalue_form_alter (hook_field_widget_multivalue_WIDGET_TYPE_form_alter).

aaron.ferris’s picture

Im seeing fatals calling this hook with the exact parameter structure as above

I think it should be

hook_field_widget_complete_form_alter(&$field_widget_complete_form, \Drupal\Core\Form\FormStateInterface $form_state, $context) {

mlncn’s picture

Yeah, it's a bad habit in documentation to not include the use statement, which in this case is:

use Drupal\Core\Form\FormStateInterface;

because they typically are placed at the top of the file.

benjamin, Agaric

aaron.ferris’s picture

Yes indeed, we need something for anyone copying like for like. My example/use, either is fine imo, most documentation follows the former.