You are here

function fc_entityreference_field_is_complete in Field Complete 7

1 string reference to 'fc_entityreference_field_is_complete'
entityreference.inc in plugins/fields/entityreference.inc

File

plugins/fields/entityreference.inc, line 22

Code

function fc_entityreference_field_is_complete($items, $instance, $field, &$completed = array()) {
  $module = $field['module'];
  $check_entities = !empty($instance['settings']['fc']['fc_check_entities']);
  $entity_type = $field['settings']['target_type'];
  foreach ($items as $delta => $item) {
    if ($check_entities) {

      // Loads each entity to find out whether it is complete
      $entity = entity_load($entity_type, array(
        $item['target_id'],
      ));
      $entity = reset($entity);
      $completed[] = $entity->fc->complete;
    }
    else {

      // Just do a superficial check of item
      $completed[$delta] = !module_invoke($module, 'field_is_empty', $item, $field);
    }
  }
}