public function RelationField::preSave in Relation 8
Defines custom presave behavior for field values.
This method is called during the process of saving an entity, just before item values are written into storage.
Overrides FieldItemList::preSave
See also
\Drupal\Core\Field\FieldItemInterface::preSave()
File
- relation_endpoint/
src/ Type/ RelationField.php, line 17 - Contains \Drupal\relation_endpoint\Type\RelationField.
Class
Namespace
Drupal\relation_endpoint\TypeCode
public function preSave() {
// We need r_index here because EntityFieldQuery can't query on deltas.
if (isset($this->list)) {
foreach ($this->list as $delta => &$item) {
$item->r_index = $delta;
}
}
}