Skip to main content
added 30 characters in body
Source Link
Anil Sagar
  • 12.2k
  • 2
  • 31
  • 54

Great Question :-) After re-engineering Field UI module found a simple way to retrieve above details...

  $bundle = field_extract_bundle('field_collection_item', 'field_my_collection_fields');

  $instances = field_info_instances('field_collection_item', $bundle);


  foreach ($instances as $field_name => $field_properties) {
   if ($field_properties['required'] == 1) {
     dpmdrupal_set_message($field_name . " is  required");
   }
   else {
     dpmdrupal_set_message($field_name . " is  not required");
   }
  }

Replace field_my_collection_fields with your field collection field name in above code ...

Great Question :-) After re-engineering Field UI module found a simple way to retrieve above details...

  $bundle = field_extract_bundle('field_collection_item', 'field_my_collection_fields');

  $instances = field_info_instances('field_collection_item', $bundle);


  foreach ($instances as $field_name => $field_properties) {
   if ($field_properties['required'] == 1) {
     dpm($field_name . " is  required");
   }
   else {
     dpm($field_name . " is  not required");
   }
  }

Replace field_my_collection_fields with your field collection field name in above code ...

Great Question :-) After re-engineering Field UI module found a simple way to retrieve above details...

  $bundle = field_extract_bundle('field_collection_item', 'field_my_collection_fields');

  $instances = field_info_instances('field_collection_item', $bundle);


  foreach ($instances as $field_name => $field_properties) {
   if ($field_properties['required'] == 1) {
     drupal_set_message($field_name . " is  required");
   }
   else {
     drupal_set_message($field_name . " is  not required");
   }
  }

Replace field_my_collection_fields with your field collection field name in above code ...

Source Link
Anil Sagar
  • 12.2k
  • 2
  • 31
  • 54

Great Question :-) After re-engineering Field UI module found a simple way to retrieve above details...

  $bundle = field_extract_bundle('field_collection_item', 'field_my_collection_fields');

  $instances = field_info_instances('field_collection_item', $bundle);


  foreach ($instances as $field_name => $field_properties) {
   if ($field_properties['required'] == 1) {
     dpm($field_name . " is  required");
   }
   else {
     dpm($field_name . " is  not required");
   }
  }

Replace field_my_collection_fields with your field collection field name in above code ...