TestItemWithPreconfiguredOptions.php

Same filename in other branches
  1. 9 core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php
  2. 8.9.x core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php
  3. 10 core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php

Namespace

Drupal\field_test\Plugin\Field\FieldType

File

core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithPreconfiguredOptions.php

View source
<?php

declare (strict_types=1);
namespace Drupal\field_test\Plugin\Field\FieldType;

use Drupal\Core\Field\Attribute\FieldType;
use Drupal\Core\Field\FieldStorageDefinitionInterface;
use Drupal\Core\Field\PreconfiguredFieldUiOptionsInterface;
use Drupal\Core\StringTranslation\TranslatableMarkup;

/**
 * Defines the 'test_field_with_preconfigured_options' entity field item.
 */
class TestItemWithPreconfiguredOptions extends TestItem implements PreconfiguredFieldUiOptionsInterface {
    
    /**
     * {@inheritdoc}
     */
    public static function getPreconfiguredOptions() {
        return [
            'custom_options' => [
                'label' => new TranslatableMarkup('All custom options'),
                'field_storage_config' => [
                    'cardinality' => FieldStorageDefinitionInterface::CARDINALITY_UNLIMITED,
                    'settings' => [
                        'test_field_storage_setting' => 'preconfigured_storage_setting',
                    ],
                ],
                'field_config' => [
                    'required' => TRUE,
                    'settings' => [
                        'test_field_setting' => 'preconfigured_field_setting',
                    ],
                ],
                'entity_form_display' => [
                    'type' => 'test_field_widget_multiple',
                ],
                'entity_view_display' => [
                    'type' => 'field_test_multiple',
                ],
            ],
        ];
    }

}

Classes

Title Deprecated Summary
TestItemWithPreconfiguredOptions Defines the 'test_field_with_preconfigured_options' entity field item.

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