field_ui_test_deprecated.module

Same filename in other branches
  1. 11.x core/modules/field_ui/tests/modules/field_ui_test_deprecated/field_ui_test_deprecated.module

Field UI test module.

File

core/modules/field_ui/tests/modules/field_ui_test_deprecated/field_ui_test_deprecated.module

View source
<?php


/**
 * @file
 * Field UI test module.
 */
use Drupal\Core\Form\FormStateInterface;
use Drupal\field\FieldStorageConfigInterface;
use Drupal\field_ui\Form\FieldStorageConfigEditForm;

/**
 * Implements hook_form_FORM_ID_alter() for field_storage_config_edit_form.
 */
function field_ui_test_deprecated_form_field_storage_config_edit_form_alter(&$form, FormStateInterface $form_state) {
    if (!$form_state->getFormObject() instanceof FieldStorageConfigEditForm) {
        throw new \LogicException('field_storage_config_edit_form() expects to get access to the field storage config entity edit form.');
    }
    if (!$form_state->getFormObject()
        ->getEntity() instanceof FieldStorageConfigInterface) {
        throw new \LogicException('field_storage_config_edit_form() expects to get access to the field storage config entity.');
    }
    if (!isset($form['cardinality_container']['cardinality'])) {
        throw new \LogicException('field_storage_config_edit_form() expects to that the cardinality container with the cardinality form element exists.');
    }
    $form['cardinality_container']['hello'] = [
        '#markup' => 'Greetings from the field_storage_config_edit_form() alter.',
    ];
}

Functions

Title Deprecated Summary
field_ui_test_deprecated_form_field_storage_config_edit_form_alter Implements hook_form_FORM_ID_alter() for field_storage_config_edit_form.

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