1

I have a field collection with the name 'field_stk_fld1'.

Inside this field collection('field_stk_fld1') there is a field with name 'field_fld_stk_ques1'.

I wanted to extract label of the field ('field_fld_stk_ques1'), Any idea on how to get it?

Note: This field ('field_fld_stk_ques1') is used in multiple places and in each place it has its own label associated.

2

This should do it:

$entity_type = 'field_collection_item';
$bundle_name = 'field_some_field'; // Field name the collection is attached to
$field_name = 'field_some_other_field'; // Field name within the field collection

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

if ($info) {
  $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.