function computed_field_field_is_empty in Computed Field 7
Implements hook_field_is_empty().
File
- ./
computed_field.module, line 473 - Functionality for the computed field.
Code
function computed_field_field_is_empty($item, $field) {
unset($empty);
// This will depend on the class of data type.
switch ($field['settings']['database']['data_type']) {
case 'int':
case 'float':
case 'numeric':
// For numbers, the field is empty if the value isn't numeric.
$empty = !is_numeric($item['value']);
break;
case 'varchar':
case 'text':
case 'longtext':
// For strings, the field is empty if it doesn't match the empty string.
$empty = $item['value'] === '';
break;
}
return $empty;
}