_field_filter_items

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 _field_filter_items($field, $items)

Helper function to filter out empty field values.

Parameters

$field The field definition.

$items The field values to filter.

Return value

The array of items without empty field values. The function also renumbers the array keys to ensure sequential deltas.

Related topics

Code

modules/field/field.module, line 516

<?php
function _field_filter_items($field, $items) {
  $function = $field['module'] . '_field_is_empty';
  function_exists($function);
  foreach ((array) $items as $delta => $item) {
    // Explicitly break if the function is undefined.
    if ($function($item, $field)) {
      unset($items[$delta]);
    }
  }
  return array_values($items);
}
?>