Skip to main content
3 of 3
deleted 24 characters in body
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133

I'm sure that this is not the best option but at least it works.

Go to admin/structure/types/manage/YOUR_CONTENT_TYPE/display and select the Title Formatter for your field, and then use this code:

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $i => $delta) {   
  dpm($delta->value);
  dpm($node->field_aaaa->view('full')[$i]['#markup']);
}

You will see this:

* id_string1
* String 1
* id_string2
* String 2
* id_string3
* String 3

EDIT: The correct way using the @4k4 answer is:

$nid = 76;
$node = \Drupal::service('entity.manager')->getStorage('node')->load($nid);
foreach ($node->field_aaaa as $i => $delta) {   
  dpm($delta->value);
  dpm((string) \Drupal::service('renderer')->render($delta->view(array('type' => 'title_formatter'))));
}
Adrian Cid Almaguer
  • 18.5k
  • 14
  • 79
  • 133