field_third_party_test.module 1.82 KB
Newer Older
1 2
<?php

3 4 5 6 7
/**
 * @file
 * Test module.
 */

8 9 10
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FormatterInterface;
use Drupal\Core\Field\WidgetInterface;
11 12
use Drupal\Core\Form\FormStateInterface;

13 14 15
/**
 * Implements hook_field_widget_third_party_settings_form().
 */
16
function field_third_party_test_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
  $element['field_test_widget_third_party_settings_form'] = array(
    '#type' => 'textfield',
    '#title' => t('3rd party widget settings form'),
    '#default_value' => $plugin->getThirdPartySetting('field_third_party_test', 'field_test_widget_third_party_settings_form'),
  );
  return $element;
}

/**
 * Implements hook_field_widget_settings_summary_alter().
 */
function field_third_party_test_field_widget_settings_summary_alter(&$summary, $context) {
  $summary[] = 'field_test_field_widget_settings_summary_alter';
  return $summary;
}

/**
 * Implements hook_field_formatter_third_party_settings_form().
 */
36
function field_third_party_test_field_formatter_third_party_settings_form(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) {
37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
  $element['field_test_field_formatter_third_party_settings_form'] = array(
    '#type' => 'textfield',
    '#title' => t('3rd party formatter settings form'),
    '#default_value' => $plugin->getThirdPartySetting('field_third_party_test', 'field_test_field_formatter_third_party_settings_form'),
  );
  return $element;
}

/**
 * Implements hook_field_formatter_settings_summary_alter().
 */
function field_third_party_test_field_formatter_settings_summary_alter(&$summary, $context) {
  $summary[] = 'field_test_field_formatter_settings_summary_alter';
  return $summary;
}