diff --git a/core/modules/block_content/migration_templates/block_content_body_field.yml b/core/modules/block_content/migration_templates/block_content_body_field.yml index 41484f8..388a8f7 100644 --- a/core/modules/block_content/migration_templates/block_content_body_field.yml +++ b/core/modules/block_content/migration_templates/block_content_body_field.yml @@ -12,6 +12,7 @@ source: field_name: body label: Body display_summary: false + allowed_formats: { } ids: entity_type: type: string diff --git a/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php b/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php index 2b04399..379cea5 100644 --- a/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php +++ b/core/modules/field/src/Tests/Migrate/d6/MigrateFieldInstanceTest.php @@ -78,7 +78,10 @@ public function testFieldInstanceSettings() { // Test a text field. $field = FieldConfig::load('node.story.field_test'); $this->assertIdentical('Text Field', $field->label()); - $expected = array('max_length' => 255); + $expected = array( + 'allowed_formats' => array(), + 'max_length' => 255, + ); $this->assertIdentical($expected, $field->getSettings()); $this->assertIdentical('text for default value', $entity->field_test->value); diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php index fab3843..259ef64 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextareaWidget.php @@ -30,14 +30,15 @@ class TextareaWidget extends StringTextareaWidget { */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $main_widget = parent::formElement($items, $delta, $element, $form, $form_state); + $allowed_formats_setting = $this->getFieldSetting('allowed_formats'); $element = $main_widget['value']; $element['#type'] = 'text_format'; $element['#format'] = $items[$delta]->format; $element['#base_type'] = $main_widget['value']['#type']; - if (is_array($this->getFieldSetting('allowed_formats'))) { - $allowed_formats = array_filter($this->getFieldSetting('allowed_formats')); + if (is_array($allowed_formats_setting)) { + $allowed_formats = array_filter($allowed_formats_setting); if (!empty($allowed_formats) && !$this->isDefaultValueWidget($form_state)) { $element['#allowed_formats'] = $allowed_formats; } diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php index b0c0674..1834053 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php @@ -30,14 +30,15 @@ class TextfieldWidget extends StringTextfieldWidget { */ public function formElement(FieldItemListInterface $items, $delta, array $element, array &$form, FormStateInterface $form_state) { $main_widget = parent::formElement($items, $delta, $element, $form, $form_state); + $allowed_formats_setting = $this->getFieldSetting('allowed_formats'); $element = $main_widget['value']; $element['#type'] = 'text_format'; $element['#format'] = isset($items[$delta]->format) ? $items[$delta]->format : NULL; $element['#base_type'] = $main_widget['value']['#type']; - if (is_array($this->getFieldSetting('allowed_formats'))) { - $allowed_formats = array_filter($this->getFieldSetting('allowed_formats')); + if (is_array($allowed_formats_setting)) { + $allowed_formats = array_filter($allowed_formats_setting); if (!empty($allowed_formats) && !$this->isDefaultValueWidget($form_state)) { $element['#allowed_formats'] = $allowed_formats; }