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

The $field and $instance arrays from Drupal 7 are configuration entities in Drupal 8. Additionally, the only code that interacts with these objects directly should be code that changes or stores their configuration, or reacts to the configuration being changed.

Formatters, widgets, and other code that acts on fields without changing or storing their configuration, instead receive a $field_definition object that implements FieldDefinitionInterface. The data returned via methods of this interface might be internally stored in the $field configuration entity, or in the $instance configuration entity, or represent a nonconfigurable, code-defined, field for which there is no configuration entity at all. Formatters, widgets, etc. have no reason to know or care about any of those internal details.

Code example:

Drupal 7:

<?php
function options_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  ...
 
$field_type = $field['type'];
 
$required = $instance['required'];
 
$cardinality = $field['cardinality'];
 
$multiple = $cardinality > 1 || $cardinality == FIELD_CARDINALITY_UNLIMITED;
  ...
}
?>

Drupal 8:

<?php
abstract class OptionsWidgetBase extends WidgetBase {
  ...
  public function
formElement(FieldItemListInterface $items, $delta, array $element, array &$form, array &$form_state) {
    ...
   
$type = $this->fieldDefinition->getType();
   
$required = $this->fieldDefinition->isRequired();
   
$cardinality = $this->fieldDefinition->getCardinality();
   
$multiple  $this->fieldDefinition->isMultiple();
    ...
  }
}
?>

See Field widgets are now plugins for more detail about the widget example used above.

Impacts: 
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

Comments

The title of #2143263: Remove "Field" prefix from FieldDefinitionInterface methods reflects that the method getFieldSettings() changed to getSettings().