W3cubDocs

/Drupal 8

public function FieldItemBase::preSave

public FieldItemBase::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.

Overrides FieldItemInterface::preSave

File

core/lib/Drupal/Core/Field/FieldItemBase.php, line 194

Class

FieldItemBase
An entity field item.

Namespace

Drupal\Core\Field

Code

public function preSave() {
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Field!FieldItemBase.php/function/FieldItemBase::preSave/8.1.x