Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / vendor / chi-teck / drupal-code-generator / templates / d8 / hook / field_widget_multivalue_WIDGET_TYPE_form_alter.twig
diff --git a/vendor/chi-teck/drupal-code-generator/templates/d8/hook/field_widget_multivalue_WIDGET_TYPE_form_alter.twig b/vendor/chi-teck/drupal-code-generator/templates/d8/hook/field_widget_multivalue_WIDGET_TYPE_form_alter.twig
new file mode 100644 (file)
index 0000000..21ded33
--- /dev/null
@@ -0,0 +1,13 @@
+/**
+ * Implements hook_field_widget_multivalue_WIDGET_TYPE_form_alter().
+ */
+function {{ machine_name }}_field_widget_multivalue_WIDGET_TYPE_form_alter(array &$elements, \Drupal\Core\Form\FormStateInterface $form_state, array $context) {
+  // Code here will only act on widgets of type WIDGET_TYPE. For example,
+  // hook_field_widget_multivalue_mymodule_autocomplete_form_alter() will only
+  // act on widgets of type 'mymodule_autocomplete'.
+  // Change the autocomplete route for each autocomplete element within the
+  // multivalue widget.
+  foreach (Element::children($elements) as $delta => $element) {
+    $elements[$delta]['#autocomplete_route_name'] = 'mymodule.autocomplete_route';
+  }
+}