diff -u b/core/modules/block_content/block_content.module b/core/modules/block_content/block_content.module --- b/core/modules/block_content/block_content.module +++ b/core/modules/block_content/block_content.module @@ -87,17 +87,17 @@ 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_type_id, 'label' => $label, - 'settings' => [ - 'display_summary' => FALSE, - 'allowed_formats' => [], - ], + 'settings' => ['display_summary' => FALSE], ]); $field->save(); 'field_storage' => FieldStorageConfig::loadByName('block_content', 'body'), 'bundle' => $block_type_id, 'label' => $label, - 'settings' => ['display_summary' => FALSE], + 'settings' => [ + 'display_summary' => FALSE, + 'allowed_formats' => [], + ], ]); $field->save(); diff -u b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php --- b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php +++ b/core/modules/ckeditor/tests/src/FunctionalJavascript/CKEditorIntegrationTest.php @@ -73,10 +73,7 @@ 'field_storage' => $field_storage, 'bundle' => 'page', 'label' => 'Body', - 'settings' => [ - 'display_summary' => TRUE, - 'allowed_formats' => [], - ], + 'settings' => ['display_summary' => TRUE], 'required' => TRUE, ])->save(); @@ -84,7 +81,10 @@ 'field_storage' => $field_storage, 'bundle' => 'page', 'label' => 'Body', - 'settings' => ['display_summary' => TRUE], + 'settings' => [ + 'display_summary' => TRUE, + 'allowed_formats' => [], + ], 'required' => TRUE, ])->save(); 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 @@ -81,7 +81,8 @@ ->setRequired(TRUE); $properties['format'] = DataDefinition::create('filter_format') - ->setLabel(t('Text format')); + ->setLabel(t('Text format')) + ->setSetting('allowed_formats', $field_definition->getSetting('allowed_formats')); $properties['processed'] = DataDefinition::create('string') ->setLabel(t('Processed text')) @@ -153,22 +154,2 @@ - /** - * {@inheritdoc} - */ - public function getConstraints() { - $constraint_manager = \Drupal::typedDataManager()->getValidationConstraintManager(); - $constraints = parent::getConstraints(); - - if ($formats = $this->getSetting('allowed_formats')) { - $constraints[] = $constraint_manager->create('ComplexData', [ - 'format' => [ - 'AllowedValues' => [ - 'choices' => $formats, - ], - ], - ]); - } - - return $constraints; - } - } 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 @@ -177,14 +177,14 @@ 'format' => mb_strtolower($this->randomMachineName()), 'name' => $this->randomMachineName(), ]); - $format1_id = $format1->id(); + $format1->save(); // Create a second text format. $format2 = FilterFormat::create([ 'format' => mb_strtolower($this->randomMachineName()), 'name' => $this->randomMachineName(), ]); - $format1_id = $format1->id(); + $format2->save(); // Grant access to both formats to the user. $roles = $this->webUser->getRoles(); @@ -232,7 +232,7 @@ // Change field to allow only one format. $path = "entity_test/structure/entity_test/fields/entity_test.entity_test.$field_name"; $this->drupalGet($path); - $this->submitForm(["settings[allowed_formats][$format1_id]" => $format1_id], 'Save settings'); + $this->submitForm(["settings[allowed_formats][{$format1->id()}]" => $format1->id()], 'Save settings'); $this->drupalGet($path); // Display the creation form. $this->drupalLogin($this->webUser); diff -u b/core/modules/text/text.install b/core/modules/text/text.install --- b/core/modules/text/text.install +++ b/core/modules/text/text.install @@ -12,7 +12,7 @@ /** * Add allowed_formats setting to existing text fields. */ -function text_update_9201(&$sandbox) { +function text_update_10101(&$sandbox) { \Drupal::classResolver(ConfigEntityUpdater::class) ->update($sandbox, 'field_config', function (FieldConfigInterface $field_config) { $class = get_class($field_config);