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

The field_form_set_state() / field_form_get_state() functions were used in D7, mostly by field widgets, to safely place and retrieve data in $form_state without clashing with other fields in the form or other embedded subforms.

In D8, those have been moved to static getWidgetState() / setWidgetState() methods on WidgetBaseInterface.

Example

Drupal 7:

$state = field_form_get_state($parents, $field_name, $langcode, $form_state);
$state['foo'] = 'bar';
field_form_set_state($parents, $field_name, $langcode, $form_state, $state);

Drupal 8:

$state = \Drupal\Core\Field\WidgetBase::getWidgetState($parents, $field_name, $form_state);
// (or static::getWidgetState if the code lives in a widget class)
$state['foo'] = 'bar';
\Drupal\Core\Field\WidgetBase::getWidgetState($parents, $field_name, $form_state, $state);
// (or static::setWidgetState if the code lives in a widget class)
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

abhaysaraf’s picture

Typo:
\Drupal\Core\Field\WidgetBase::getWidgetState($parents, $field_name, $form_state, $state);
Must be:
\Drupal\Core\Field\WidgetBase::setWidgetState($parents, $field_name, $form_state, $state);