Skip to content

Multiple fields at same time

David Flores requested to merge feature/multiple-fields into 9.1.x

Obtain multiple fields at the same time and rename the path with a custom name

   $nodeValues = using($node)->values([
      'time' => 'field_date_date_time_single',
      'media_names'=> 'field_media_multi',
      'id' => 'nid',
      'title_node' => 'title',
    ]);

Result:

^ Drupal\fluent\Collection {#1533 ▼
  #items: array:4 [▼
    "time" => Drupal\Core\Datetime\DrupalDateTime {#1372 ▶}
    "media_names" => array:3 [▶]
    "id" => 1
    "title_node" => "title Boolean"
  ]
  #escapeWhenCastingToString: false
}

Merge request reports

Loading