reverted: --- b/core/modules/text/src/Plugin/Field/FieldType/TextFieldItemList.php +++ /dev/null @@ -1,35 +0,0 @@ -getSetting('allowed_formats') && !empty($allowed_formats)) { - $field_name = $this->definition->getName(); - $submitted_values = $form_state->getValue([ - 'default_value_input', - $field_name, - ]); - foreach ($submitted_values as $delta => $value) { - if (!in_array($value['format'], $allowed_formats, TRUE)) { - $form_state->setErrorByName( - "default_value_input][{$field_name}][{$delta}][format", - $this->t("The selected text format is not allowed.") - ); - } - } - } - parent::defaultValuesFormValidate($element, $form, $form_state); - } - -} diff -u b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php --- b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php +++ b/core/modules/text/src/Plugin/Field/FieldType/TextItemBase.php @@ -59,9 +59,14 @@ public static function calculateDependencies(FieldDefinitionInterface $field_definition) { // Add explicitly allowed formats as config dependencies. $dependencies = parent::calculateDependencies($field_definition); - $format_dependencies = array_map(function (string $format_id) { - return 'filter.format.' . $format_id; - }, $field_definition->getSetting('allowed_formats')); + if (!is_null($field_definition->getSetting('allowed_formats'))) { + $format_dependencies = array_map(function (string $format_id) { + return 'filter.format.' . $format_id; + }, $field_definition->getSetting('allowed_formats')); + } + else { + $format_dependencies = []; + } $config = $dependencies['config'] ?? []; $dependencies['config'] = array_merge($config, $format_dependencies); return $dependencies; diff -u b/core/modules/text/tests/src/Functional/TextFieldTest.php b/core/modules/text/tests/src/Functional/TextFieldTest.php --- b/core/modules/text/tests/src/Functional/TextFieldTest.php +++ b/core/modules/text/tests/src/Functional/TextFieldTest.php @@ -265,10 +265,7 @@ * Helper function for testTextfieldWidgetsFormatted(). */ public function _testTextfieldWidgetsFormatted($field_type, $widget_type) { - /** @var \Drupal\Core\Render\RendererInterface $renderer */ - $renderer = $this->container->get('renderer'); - - // Create a field. + // Create a field. $field_name = mb_strtolower($this->randomMachineName()); $field_storage = FieldStorageConfig::create([ 'field_name' => $field_name, reverted: --- b/core/modules/text/text.install +++ /dev/null @@ -1,31 +0,0 @@ -update($sandbox, 'field_config', function (FieldConfigInterface $field_config) { - $class = get_class($field_config); - // Deal only with text fields and descendants. - if ($class == TextItemBase::class || is_subclass_of($class, TextItemBase::class)) { - // Get the existing allowed_formats setting. - $allowed_formats = $field_config->get('settings.allowed_formats'); - if (!is_array($allowed_formats) && empty($allowed_formats)) { - // Save default value if existing value not present. - $field_config->set('settings.allowed_formats', []); - } - return TRUE; - } - return FALSE; - }); -}