22/02/2025, by Anonymous (not verified) Forums Module Development 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']] ; } Log in to post comments Log in to post comments
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']] ; } Log in to post comments
Drupal fields are represented by the
ItemListclass (whether they're multi-valued or not). The convenience methodgetValue()iterates through each item'sgetValue()method to build an array representation of the data value.