Loading core/modules/field/tests/modules/field_test/field_test.field_type_categories.yml 0 → 100644 +3 −0 Original line number Diff line number Diff line field_test_descriptions: label: 'Field Test' description: 'Fields for testing descriptions.' core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithMultipleDescriptions.php 0 → 100644 +23 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\field_test\Plugin\Field\FieldType; /** * Defines the 'test_field_with_multiple_descriptions' entity field item. * * @FieldType( * id = "test_field_with_multiple_descriptions", * label = @Translation("Test field (multiple descriptions"), * description = { * @Translation("This multiple line description needs to use an array"), * @Translation("This second line contains important information"), * }, * category = "field_test_descriptions", * default_widget = "test_field_widget", * default_formatter = "field_test_default" * ) */ class TestItemWithMultipleDescriptions extends TestItem { } core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithSingleDescription.php 0 → 100644 +20 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\field_test\Plugin\Field\FieldType; /** * Defines the 'test_field_with_single_description' entity field item. * * @FieldType( * id = "test_field_with_single_description", * label = @Translation("Test field (single description"), * description = @Translation("This one-line field description is important for testing"), * category = "field_test_descriptions", * default_widget = "test_field_widget", * default_formatter = "field_test_default" * ) */ class TestItemWithSingleDescription extends TestItem { } core/modules/field_ui/src/Form/FieldStorageAddForm.php +8 −5 Original line number Diff line number Diff line Loading @@ -286,15 +286,18 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t ], ]; foreach ($unique_definitions[$selected_field_type] as $option_key => $option) { foreach ($unique_definitions[$selected_field_type] as $option) { // If the field type plugin's annotation defines description as an // array, render it as an item_list. $description = !is_array($option['description']) ? $option['description'] : [ '#theme' => 'item_list', '#items' => $option['description'], ]; $radio_element = [ '#type' => 'radio', '#theme_wrappers' => ['form_element__new_storage_type'], '#title' => $option['label'], '#description' => [ '#theme' => 'item_list', '#items' => $unique_definitions[$selected_field_type][$option_key]['description'], ], '#description' => $description, '#id' => $option['unique_identifier'], '#weight' => $option['weight'], '#parents' => ['group_field_options_wrapper'], Loading core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php +10 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,16 @@ public function testAddField() { 'type' => 'article', ]); // Make sure field descriptions appear, both 1 line and multiple lines. $this->drupalGet('/admin/structure/types/manage/' . $type->id() . '/fields/add-field'); $edit = [ 'new_storage_type' => 'field_test_descriptions', ]; $this->submitForm($edit, 'Continue'); $this->assertSession()->pageTextContains('This one-line field description is important for testing'); $this->assertSession()->pageTextContains('This multiple line description needs to use an array'); $this->assertSession()->pageTextContains('This second line contains important information'); // Create a new field without actually saving it. $this->fieldUIAddNewField('admin/structure/types/manage/' . $type->id(), 'test_field', 'Test field', 'test_field', [], [], FALSE); // Assert that the field was not created. Loading Loading
core/modules/field/tests/modules/field_test/field_test.field_type_categories.yml 0 → 100644 +3 −0 Original line number Diff line number Diff line field_test_descriptions: label: 'Field Test' description: 'Fields for testing descriptions.'
core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithMultipleDescriptions.php 0 → 100644 +23 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\field_test\Plugin\Field\FieldType; /** * Defines the 'test_field_with_multiple_descriptions' entity field item. * * @FieldType( * id = "test_field_with_multiple_descriptions", * label = @Translation("Test field (multiple descriptions"), * description = { * @Translation("This multiple line description needs to use an array"), * @Translation("This second line contains important information"), * }, * category = "field_test_descriptions", * default_widget = "test_field_widget", * default_formatter = "field_test_default" * ) */ class TestItemWithMultipleDescriptions extends TestItem { }
core/modules/field/tests/modules/field_test/src/Plugin/Field/FieldType/TestItemWithSingleDescription.php 0 → 100644 +20 −0 Original line number Diff line number Diff line <?php declare(strict_types=1); namespace Drupal\field_test\Plugin\Field\FieldType; /** * Defines the 'test_field_with_single_description' entity field item. * * @FieldType( * id = "test_field_with_single_description", * label = @Translation("Test field (single description"), * description = @Translation("This one-line field description is important for testing"), * category = "field_test_descriptions", * default_widget = "test_field_widget", * default_formatter = "field_test_default" * ) */ class TestItemWithSingleDescription extends TestItem { }
core/modules/field_ui/src/Form/FieldStorageAddForm.php +8 −5 Original line number Diff line number Diff line Loading @@ -286,15 +286,18 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t ], ]; foreach ($unique_definitions[$selected_field_type] as $option_key => $option) { foreach ($unique_definitions[$selected_field_type] as $option) { // If the field type plugin's annotation defines description as an // array, render it as an item_list. $description = !is_array($option['description']) ? $option['description'] : [ '#theme' => 'item_list', '#items' => $option['description'], ]; $radio_element = [ '#type' => 'radio', '#theme_wrappers' => ['form_element__new_storage_type'], '#title' => $option['label'], '#description' => [ '#theme' => 'item_list', '#items' => $unique_definitions[$selected_field_type][$option_key]['description'], ], '#description' => $description, '#id' => $option['unique_identifier'], '#weight' => $option['weight'], '#parents' => ['group_field_options_wrapper'], Loading
core/modules/field_ui/tests/src/Functional/ManageFieldsTest.php +10 −0 Original line number Diff line number Diff line Loading @@ -136,6 +136,16 @@ public function testAddField() { 'type' => 'article', ]); // Make sure field descriptions appear, both 1 line and multiple lines. $this->drupalGet('/admin/structure/types/manage/' . $type->id() . '/fields/add-field'); $edit = [ 'new_storage_type' => 'field_test_descriptions', ]; $this->submitForm($edit, 'Continue'); $this->assertSession()->pageTextContains('This one-line field description is important for testing'); $this->assertSession()->pageTextContains('This multiple line description needs to use an array'); $this->assertSession()->pageTextContains('This second line contains important information'); // Create a new field without actually saving it. $this->fieldUIAddNewField('admin/structure/types/manage/' . $type->id(), 'test_field', 'Test field', 'test_field', [], [], FALSE); // Assert that the field was not created. Loading