You are here

function field_test_field_widget_form_alter in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 core/modules/field/tests/modules/field_test/field_test.module \field_test_field_widget_form_alter()

Implements hook_field_widget_form_alter().

File

core/modules/field/tests/modules/field_test/field_test.module, line 101

Code

function field_test_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
  $field_definition = $context['items']
    ->getFieldDefinition();
  switch ($field_definition
    ->getName()) {
    case 'alter_test_text':
      drupal_set_message('Field size: ' . $context['widget']
        ->getSetting('size'));
      break;
    case 'alter_test_options':
      drupal_set_message('Widget type: ' . $context['widget']
        ->getPluginId());
      break;
  }

  // Set a message if this is for the form displayed to set default value for
  // the field.
  if ($context['default']) {
    drupal_set_message('From hook_field_widget_form_alter(): Default form is true.');
  }
}