You are here

function multifield_field_is_empty in Multifield 7.2

Same name and namespace in other branches
  1. 7 multifield.field.inc \multifield_field_is_empty()

Implements hook_field_is_empty().

File

./multifield.field.inc, line 302
Field integration for the Multifield module.

Code

function multifield_field_is_empty($item, $field) {
  $machine_name = multifield_extract_multifield_machine_name($field);
  $subinstances = field_info_instances('multifield', $machine_name);
  foreach ($subinstances as $subfield_name => $subinstance) {
    if (!empty($item[$subfield_name])) {
      $subfield = field_info_field($subfield_name);
      foreach ($item[$subfield_name] as $langcode => $subfield_items) {
        $item[$subfield_name][$langcode] = _field_filter_items($subfield, $subfield_items);
      }
      $item[$subfield_name] = array_filter($item[$subfield_name]);
    }
  }
  return !array_filter(array_intersect_key($item, $subinstances));
}