You are here

function select2_all_field_widget_form_alter in Select2 ALL THE THINGS! 8

Implements hook_field_widget_form_alter().

See also

\Drupal\select2_all\Select2::preRenderSelect()

File

./select2_all.module, line 35
Hooks for the Select2 All module.

Code

function select2_all_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {

  /** @var \Drupal\Core\Field\FieldDefinitionInterface $field_definition */
  $field_definition = $context['items']
    ->getFieldDefinition();
  $element['#entity_type'] = $field_definition
    ->getTargetEntityTypeId();
  $element['#bundle'] = $field_definition
    ->getTargetBundle();
}