function hook_field_is_empty

Define what constitutes an empty item for a field type.

Parameters

$item: An item that may or may not be empty.

$field: The field to which $item belongs.

Return value

TRUE if $field's type considers $item not to contain any data; FALSE otherwise.

Related topics

12 functions implement hook_field_is_empty()

Note: this list is generated by pattern matching, so it may include some functions that are not actually implementations of this hook.

datetime_field_is_empty in drupal/core/modules/datetime/datetime.module
Implements hook_field_is_empty().
email_field_is_empty in drupal/core/modules/email/email.module
Implements hook_field_is_empty().
entity_reference_field_is_empty in drupal/core/modules/entity_reference/entity_reference.module
Implements hook_field_is_empty().
field_test_field_is_empty in drupal/core/modules/field/tests/modules/field_test/field_test.field.inc
Implements hook_field_is_empty().
file_field_is_empty in drupal/core/modules/file/file.field.inc
Implements hook_field_is_empty().

... See full list

File

drupal/core/modules/field/field.api.php, line 664

Code

function hook_field_is_empty($item, $field) {
  if (empty($item['value']) && (string) $item['value'] !== '0') {
    return TRUE;
  }
  return FALSE;
}