function FieldItemInterface::preSave
Same name in other branches
- 9 core/lib/Drupal/Core/Field/FieldItemInterface.php \Drupal\Core\Field\FieldItemInterface::preSave()
- 10 core/lib/Drupal/Core/Field/FieldItemInterface.php \Drupal\Core\Field\FieldItemInterface::preSave()
- 11.x core/lib/Drupal/Core/Field/FieldItemInterface.php \Drupal\Core\Field\FieldItemInterface::preSave()
Defines custom presave behavior for field values.
This method is called during the process of saving an entity, just before values are written into storage. When storing a new entity, its identifier will not be available yet. This should be used to massage item property values or perform any other operation that needs to happen before values are stored. For instance this is the proper phase to auto-create a new entity for an entity reference field item, because this way it will be possible to store the referenced entity identifier.
1 method overrides FieldItemInterface::preSave()
- FieldItemBase::preSave in core/
lib/ Drupal/ Core/ Field/ FieldItemBase.php - Defines custom presave behavior for field values.
File
-
core/
lib/ Drupal/ Core/ Field/ FieldItemInterface.php, line 189
Class
- FieldItemInterface
- Interface for entity field items.
Namespace
Drupal\Core\FieldCode
public function preSave();
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.