You are here

function relation_add_item_is_empty in Relation add 7

Determines whether an item is empty.

1 call to relation_add_item_is_empty()
relation_add_field_is_empty in ./relation_add.module
Implements hook_field_is_empty().

File

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

Code

function relation_add_item_is_empty($fields) {
  $is_empty = TRUE;
  foreach ($fields as $field_name => $items) {
    $field = field_info_field($field_name);

    // Determine the list of languages to iterate on.
    $languages = field_available_languages('relation', $field);
    foreach ($languages as $langcode) {
      if (!empty($items[$langcode])) {

        // If at least one relation-field is not empty; the
        // relation item is not empty.
        foreach ($items[$langcode] as $field_item) {
          if (!module_invoke($field['module'], 'field_is_empty', $field_item, $field)) {
            $is_empty = FALSE;
          }
        }
      }
    }
  }
  return $is_empty;
}