Change record status: 
Project: 
Introduced in branch: 
8.0.x
Description: 

In Drupal 7, text field types (....) had an option to enable text processing (being able to select a text filter).

In Drupal 8, this option has been removed, there are now different field types instead for text processing or without.

There are also separate widgets and formatters for the different field types, it is no longer possible to display a text field with a text format as a plain text.

As a side effect of this, it is no longer possible to switch a field between using text formats and plain text.

For developers:

The new plain text field types have the machine names string and string_long. They were already used for base fields and are now exposed in the UI with new field type labels.

For consistency, the 'list_text' field type has been renamed to 'list_string'

Impacts: 
Site builders, administrators, editors
Module developers

Comments

JulienD’s picture

To apply this code change there are two places where string needs to be updated to string_textfield:

Actions :
* Rename the field type from ’string’ to ‘string_textfield'
* Remove the ‘text_processing’ setting that is not required anymore because it’s now inherent to the selected type.

Update your base field definition of your entity type class

Example with the Commerce Product entity (modules/product/src/Entity/CommerceProduct.php

Before

  $fields['title'] = BaseFieldDefinition::create('string')
    ->setLabel(t('Title'))
    ->setDescription(t('The title of this node, always treated as non-markup plain text.'))
    ->setRequired(TRUE)
    ->setTranslatable(TRUE)
    ->setRevisionable(TRUE)
    ->setSettings(array(
	'default_value' => '',
	'max_length' => 255,
-      'text_processing' => 0,
    ))
    ->setDisplayOptions('view', array(
	'label' => 'hidden',
	'type' => 'string',
	'weight' => -5,
    ))
    ->setDisplayOptions('form', array(
- 	'type' => 'string',
	'weight' => -5,
    ))
    ->setDisplayConfigurable('form', TRUE);

After

    $fields['title'] = BaseFieldDefinition::create('string')
	->setLabel(t('Title'))
	->setDescription(t('The title of this node, always treated as non-markup plain text.'))
	->setRequired(TRUE)
	->setTranslatable(TRUE)
	->setRevisionable(TRUE)
	->setSettings(array(
            'default_value' => '',
	    'max_length' => 255,
	))
	->setDisplayOptions('view', array(
	    'label' => 'hidden',
	    'type' => 'string',
	    'weight' => -5,
	))
	->setDisplayOptions('form', array(
+	    'type' => 'string_textfield',
	    'weight' => -5,
	))
	->setDisplayConfigurable('form', TRUE);

Update the entity form display in it’s yaml file

Example with commerce_product.product.default.yml

Before

  content:
    title:
-    type: string
      weight: 0
      settings:
        size: 60
        placeholder: ''
      third_party_settings: {  }
    sku:
-    type: string
      weight: 2
      settings:
        size: 60
        placeholder: ''
      third_party_settings: {  }
    body:

After

  content:
    title:
+   type: string_textfield
      weight: 0
      settings:
        size: 60
        placeholder: ''
      third_party_settings: {  }
    sku:
+   type: string_textfield
      weight: 2
      settings:
        size: 60
        placeholder: ''
      third_party_settings: {  }
    body:

JulienD