I am using Drupal 8 for a project for learning purposes. In my case I want to access to a field which contains multiple values, but I can't find how to do that. For example for a single value field I can access it like this:


But how can I get all the values of field which allows more than one value?

  • contain more than user you mean more than 1 value?
    – No Sssweat
    Mar 3, 2020 at 12:38
  • yeep that's it ::) Mar 3, 2020 at 13:09

1 Answer 1


To get all values of a multi-value field:

$node = $variables['node'];
$values = array();
foreach ($node->field_name->getValue() as $value) {
  if (!empty($value['value'])) {
    $values[] = $value['value'];


$node = $variables['node'];
$values = array();
foreach ($node->field_name as $item) {
  if (!empty($item->value)) {
    $values[] = $item->value;

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.