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

In Drupal 7 field widget settings were stored with the field instance. Drupal 8 introduces the concept of entity form displays, opening the possibility of different form display modes that will allow different representations of an entity form and its fields/widgets in different contexts (similar to the way view modes work with field formatters).

Drupal 7

$field = field_create_field(array(
  'field_name' => 'field_foo',
  'cardinality' => 1,
  'type'        => 'taxonomy_term_reference',
));
$instance = field_create_instance('node', 'field_foo', array(
  'entity_type' => 'node',
  'bundle' => 'article',
  'field_name' => 'field_foo',
  'label'       => t('Foo Terms'),
  'widget'      => array(
    'type'    => 'taxonomy_autocomplete',
  ),
  'display' => array(
    'default' => array(
      'label' => 'hidden',
      'type' => 'taxonomy_term_reference_link',
    ),
  )
));

Drupal 8

$field = FieldStorageConfig::create(array(
  'type' => 'taxonomy_term_reference',
  'field_name' => 'field_foo',
  'cardinality' => 1
))->save();
$field = FieldConfig::create(array(
  'entity_type' => 'node',
  'bundle' => 'article',
  'field_name' => 'field_foo',
  'label' => t('Foo Terms')
))->save();
entity_get_form_display('node', 'article', 'default')
  ->setComponent('field_foo', array(
    'type' => 'taxonomy_autocomplete',
    'weight' => 1,
  ))
  ->save();
entity_get_display('node', 'article', 'default')
  ->setComponent('field_foo', array(
    'type' => 'taxonomy_term_reference_link',
    'weight' => 1,
  ))
  ->save();

Modules that want to ship default form display configuration (widget type, widget settings, weight, etc..) for fields can create default configuration files in their ./config folder to describe the entity form display.

Example from core/profiles/standard/config/install/entity.form_display.node.article.default.yml

id: node.article.default
targetEntityType: node
bundle: article
mode: default
content:
  body:
    type: text_textarea_with_summary
    weight: '0'
    settings:
      rows: '9'
      summary_rows: '3'
      placeholder: ''
  field_tags:
    type: taxonomy_autocomplete
    weight: '-4'
    settings:
      size: '60'
      autocomplete_path: taxonomy/autocomplete
      placeholder: ''
  field_image:
    type: image_image
    settings:
      progress_indicator: throbber
      preview_image_style: thumbnail
    weight: '-1'

The following hooks were removed:

hook_field_widget_properties_alter
hook_field_widget_properties_ENTITY_TYPE_alter

Rather than altering widgets within a form, set up a new display mode and configure the widget as required.

Impacts: 
Site builders, administrators, editors
Module developers
Updates Done (doc team, etc.)
Online documentation: 
Not done
Theming guide: 
Not done
Module developer documentation: 
Not done
Examples project: 
Not done
Coder Review: 
Not done
Coder Upgrade: 
Not done
Other: 
Other updates done