You are here

function relation_add_field_is_empty in Relation add 7

Implements hook_field_is_empty().

File

./relation_add.module, line 202
Relation Add module file.

Code

function relation_add_field_is_empty($item, $field) {
  if (empty($item['relation_options'])) {
    return TRUE;
  }
  if (!isset($item['relation_options']['rid']) && !isset($item['rid'])) {
    if (isset($item['relation_options']['targets'])) {
      $targets_flip = array_flip($item['relation_options']['targets']);
      if (count($targets_flip) < 2) {
        $target_key = array_shift($targets_flip);
        if (empty($item['relation_options']['targets'][$target_key])) {
          return TRUE;
        }
      }
    }
    else {
      return relation_add_item_is_empty($item['relation_options']);
    }
  }
  return FALSE;
}