diff --git a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php index 1063a94..522dc7c 100644 --- a/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php @@ -14,7 +14,6 @@ */ abstract class TextItemBase extends FieldItemBase { - /** * {@inheritdoc} */ @@ -22,6 +21,9 @@ public static function defaultFieldSettings() { return ['allowed_formats' => []] + parent::defaultFieldSettings(); } + /** + * {@inheritdoc} + */ public function fieldSettingsForm(array $form, FormStateInterface $form_state) { $element = parent::fieldSettingsForm($form, $form_state); $settings = $this->getSettings(); diff --git a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php index 8d4cd03..9916a98 100644 --- a/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php +++ b/core/modules/text/src/Plugin/Field/FieldWidget/TextfieldWidget.php @@ -25,18 +25,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'); + $allowed_formats = $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($allowed_formats_setting)) { - $allowed_formats = array_filter($allowed_formats_setting); - if (!empty($allowed_formats) && !$this->isDefaultValueWidget($form_state)) { - $element['#allowed_formats'] = $allowed_formats; - } + if (!empty($allowed_formats) && !$this->isDefaultValueWidget($form_state)) { + $element['#allowed_formats'] = $allowed_formats; } return $element;