How to check if field in Field Collection is required? I'm running into a problem of programmatically checking fields in a field collection.

What I want to do is loop through all fields within a field collection and check which ones are required.

I've tried these codes so far but haven't got any positive results.

$collections = field_collection_item_load_multiple($collection_ids);
foreach ($collections as $collection) {
   foreach($collection as $key =&gt; $va) {
        if (strpos ($key, 'field') !== false) {
            if (isset($va['und']) &amp;&amp; is_array($va ['und']) &amp;&amp; isset($va['und'][0]['value'])) {
                print "Field ".$key." ".$va['und'][0]['value'];
            }
        }
    }                   
}


This shows me the data and the label of the fields, not really their properties.

Thank you for your help.
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 =&gt; $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 ...