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_form_alter.twig
1 /**
2  * Implements hook_field_widget_multivalue_form_alter().
3  */
4 function {{ machine_name }}_field_widget_multivalue_form_alter(array &$elements, \Drupal\Core\Form\FormStateInterface $form_state, array $context) {
5   // Add a css class to widget form elements for all fields of type mytype.
6   $field_definition = $context['items']->getFieldDefinition();
7   if ($field_definition->getType() == 'mytype') {
8     // Be sure not to overwrite existing attributes.
9     $elements['#attributes']['class'][] = 'myclass';
10   }
11 }