3

Say I am iterating through a list of field names, and I have loaded a particular node using entity_metadata_wrapper().

$wrapper = entity_metadata_wrapper('node', $node);

Shouldn't I be able to just grab the label by using the following command?

Or is this not the correct command to do what I want?

        foreach($field_names as $item)
        {
           $label = $wrapper->$item->label();
        }

Here's the field as it is in the actual node:

'field_grade_comment' => 
    array (size=13)
      'default_value' => null
      'description' => string '' (length=0)
      'display' => 
        array (size=4)
          'default' => 
            array (size=5)
              ...
          'email' => 
            array (size=5)
              ...
          'teaser' => 
            array (size=4)
              ...
          'node_reference_embedded_view' => 
            array (size=4)
              ...
      'label' => string 'Grade Comment' (length=13)
3

How about this?

$wrapper = entity_metadata_wrapper('node', $node);
$fields = $wrapper->getPropertyInfo();

foreach($fields as $field => $info) {
  $label = $info['label'];
}
0
$entity_type = 'node';

$bundle_name = 'article';

$field_name = 'field_some_field';

$info = field_info_instance($entity_type, $field_name, $bundle_name);

$label = $info['label'];

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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