Change record status: 
Project: 
Introduced in branch: 
12.x
Introduced in version: 
Description: 

The default entity reference selection handler (DefaultSelection) has a new include_disabled_config setting for configuration entity types with a status key, such as views, text formats and blocks. FALSE leaves disabled entities out of the referenceable entities, TRUE includes them. The default, NULL, keeps the previous behavior and includes them.

Entity reference fields to these entity types get an "Include disabled …" checkbox in their reference settings, naming the entity type, such as "Include disabled text formats". Fields saved before this change keep including disabled entities until their settings are saved again with the checkbox unchecked.

Content that references an entity that is later disabled fails validation on its next save when the field leaves disabled entities out.

Before

$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance([
  'target_type' => 'filter_format',
]);
// Returns enabled and disabled text formats.
$handler->getReferenceableEntities();

After

$handler = \Drupal::service('plugin.manager.entity_reference_selection')->getInstance([
  'target_type' => 'filter_format',
  'include_disabled_config' => FALSE,
]);
// Returns only enabled text formats.
$handler->getReferenceableEntities();

In a field's configuration (field.field.*.yml):

settings:
  handler: 'default:filter_format'
  handler_settings:
    include_disabled_config: false
Impacts: 
Site builders, administrators, editors
Module developers