From 6828366c5130d4e718cd1f376fc7292372135633 Mon Sep 17 00:00:00 2001 From: Joshua Graham Date: Wed, 3 Feb 2021 14:57:40 +1100 Subject: [PATCH] Allow themes to implement hook_field_widget_multivalue_form_alter(). --- govcms.profile | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/govcms.profile b/govcms.profile index 4c60c13c0..586552174 100644 --- a/govcms.profile +++ b/govcms.profile @@ -71,3 +71,17 @@ function govcms_field_widget_form_alter(&$element, FormStateInterface $form_stat // $context['widget']->getPluginId(). \Drupal::theme()->alter(['field_widget_form'], $element, $form_state, $context); } + +/** + * Implements hook_field_widget_multivalue_form_alter(). + */ +function govcms_field_widget_multivalue_form_alter(&$elements, FormStateInterface $form_state, $context) { + // In Drupal 7 `hook_field_widget_multivalue_form_alter` could be implemented + // by the theme, but in Drupal 8 this hook changed to being module-only. + // This hook can be critical for improving the editor experience for things + // like paragraphs. Implementing themes can access the plugin ID via + // $context['widget']->getPluginId(). + \Drupal::theme()->alter([ + 'field_widget_multivalue_form', + ], $elements, $form_state, $context); +}