By yched on
Change record status:
Published (View all published change records)
Project:
Introduced in branch:
8.x
Description:
The new Entity API and Entity Translation API in Drupal 8 provides much easier access to field values in different languages. The field_get_items() helper function has thus been removed.
Drupal 7
$items = field_get_items(EntityInterface $entity, $field_name, $langcode);
Drupal 8
$items = $entity->getTranslation($langcode)->get($field_name);
$d7like_items = $entity->getTranslation($langcode)->get($field_name)->getValue();
See the corresponding change notification for more details on the Entity Translation API.
Impacts:
Module developers
Comments
But dear, in Drupal 7 using
But dear, in Drupal 7 using this function, field_get_items() it was providing us a lot of information but the replacement you have written for Drupal 8 is just returning target_id. Can you please let me know how can i get full details like in drupal 7?
Thanks
@mahpari I don`t know what
@mahpari I don`t know what you mean by "a lot of information". The field_get_items function returned only the values for the given field, so in your case the target_id and the delta.