field_third_party_test.module

Same filename in other branches
  1. 8.9.x core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module
  2. 10 core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module
  3. 11.x core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module

Test module.

File

core/modules/field/tests/modules/field_third_party_test/field_third_party_test.module

View source
<?php


/**
 * @file
 * Test module.
 */
use Drupal\Core\Field\FieldDefinitionInterface;
use Drupal\Core\Field\FormatterInterface;
use Drupal\Core\Field\WidgetInterface;
use Drupal\Core\Form\FormStateInterface;

/**
 * Implements hook_field_widget_third_party_settings_form().
 */
function field_third_party_test_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
    $element['field_test_widget_third_party_settings_form'] = [
        '#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().
 */
function field_third_party_test_field_formatter_third_party_settings_form(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) {
    $element['field_test_field_formatter_third_party_settings_form'] = [
        '#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;
}

Functions

Title Deprecated Summary
field_third_party_test_field_formatter_settings_summary_alter Implements hook_field_formatter_settings_summary_alter().
field_third_party_test_field_formatter_third_party_settings_form Implements hook_field_formatter_third_party_settings_form().
field_third_party_test_field_widget_settings_summary_alter Implements hook_field_widget_settings_summary_alter().
field_third_party_test_field_widget_third_party_settings_form Implements hook_field_widget_third_party_settings_form().

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.