You are here

function chosen_field_widget_form_alter in Chosen 3.0.x

Same name and namespace in other branches
  1. 8.2 chosen.module \chosen_field_widget_form_alter()
  2. 6 chosen.module \chosen_field_widget_form_alter()
  3. 7.3 chosen.module \chosen_field_widget_form_alter()
  4. 7 chosen.module \chosen_field_widget_form_alter()
  5. 7.2 chosen.module \chosen_field_widget_form_alter()

Implements hook_field_widget_form_alter().

File

./chosen.module, line 53
General functions and hook implementations.

Code

function chosen_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();
}