Extra Block Types (EBT) - New Layout Builder experience❗

Extra Block Types (EBT) - styled, customizable block types: Slideshows, Tabs, Cards, Accordions and many others. Built-in settings for background, DOM Box, javascript plugins. Experience the future of layout building today.

Demo EBT modules Download EBT modules

❗Extra Paragraph Types (EPT) - New Paragraphs experience

Extra Paragraph Types (EPT) - analogical paragraph based set of modules.

Demo EPT modules Download EPT modules

Scroll

How to get value of multiple values field in Drupal 8?

22/02/2025, by Anonymous (not verified)
Permalink

Drupal fields are represented by the ItemList class (whether they're multi-valued or not). The convenience method getValue() iterates through each item's getValue() method to build an array representation of the data value.

 $manager=\Drupal::entityManager();
  $field_definition = $manager->getFieldDefinitions("node","room")["field_facilities"];
  $facilities=$field_definition->getFieldStorageDefinition()->toArray()["settings"]["allowed_values"];

  $details=array();
  foreach ($nodes as $node) {
    $facs=$node->get("field_facilities")->getValue();
    foreach ($facs as $key => $f)
      $details[]= $facilities[$f['value']] ;
  }