7.x field.module _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

2 calls to _field_filter_items()
field_default_submit in modules/field/field.default.inc
field_default_validate in modules/field/field.default.inc
Generic field validation handler.

File

modules/field/field.module, line 509
Attach custom data fields to Drupal entities.

Code

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

Comments

mogadix’s picture

Hi,

I am using ajax callback function to update a field based on a select field selection.
When I select a value it call the function, the wrapper is update and set the value, but give me that two warning above.
The line 513 is the return value from the function (return array_values($items);)

Warning: array_values() expects parameter 1 to be array, string given em _field_filter_items() (linha 513 de /var/www/001-cm_viaturas/modules/field/field.module).
Warning: Invalid argument supplied for foreach() em list_field_validate() (linha 392 de /var/www/001-cm_viaturas/modules/field/modules/list/list.module).

Can anyone help me?

Thanks.