EntityReferenceFieldItemList::$target_id
The ID of the first field item's referenced entity, if it exists.
Type: target_id
File
-
core/
lib/ Drupal/ Core/ Field/ EntityReferenceFieldItemList.php, line 31
Class
- EntityReferenceFieldItemList
- Defines an item list class for entity reference fields.
Namespace
Drupal\Core\FieldCode
public string|int|null $target_id {
get => $this->first()?->__get('target_id');
set(string|int|null $target_id) {
$item = $this->first() ?: $this->appendItem();
$item->set('target_id', $target_id);
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.