How Do I Get A Field Label By The Field Name In Drupal

how do i get a field label by the field name in drupal

How Do I Get A Field Label By The Field Name In Drupal

 |   |  0
Drupal

How do I get a field label by the field name in drupal ?

The label is set per instance (not per field) so you would use the field_info_instance() function with some appropriate arguments:

$entity_type = 'node';
$bundle_name = 'article';
$field_name = 'field_some_field';

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

$label = $info['label'];

There’s a bunch of other useful functions in the Field Info API documentation that might be helpful in case you haven’t seen it already.


0 Claps

Show your love in the form of Claps and Comments...

Comments...

No comments found. Leave your reply here.