You are here

function physical_field_is_empty in Physical Fields 7

Implements hook_field_is_empty().

File

./physical.module, line 131
Defines fields (e.g. weight and dimensions) to support describing the physical attributes of entities.

Code

function physical_field_is_empty($item, $field) {
  if ($field['type'] == 'physical_volume') {
    return !isset($item['volume']) || $item['volume'] == NULL;
  }
  elseif ($field['type'] == 'physical_weight') {
    return !isset($item['weight']) || $item['weight'] == NULL;
  }
  elseif ($field['type'] == 'physical_dimensions') {

    // If any of the dimensions are missing, consider the field empty.
    foreach (physical_dimensions() as $key => $dimension) {
      if (!isset($item[$key]) || $item[$key] == NULL) {
        return TRUE;
      }
    }
    return FALSE;
  }
}