field_has_data

  1. drupal
    1. 8
    2. 7
Versions
7 – 8 field_has_data($field)

Determine whether a field has any data.

Parameters

$field A field structure.

Return value

TRUE if the field has data for any entity; FALSE otherwise.

Related topics

▾ 3 functions call field_has_data()

field_ui_field_edit_form in modules/field_ui/field_ui.admin.inc
Menu callback; presents the field instance edit page.
field_ui_field_settings_form in modules/field_ui/field_ui.admin.inc
Menu callback; presents the field settings edit page.
field_update_field in modules/field/field.crud.inc
Updates a field.

Code

modules/field/field.module, line 981

<?php
function field_has_data($field) {
  $query = new EntityFieldQuery();
  return (bool) $query
    ->fieldCondition($field)
    ->range(0, 1)
    ->count()
    ->execute();
}
?>