You are here

function theme_mvf_formatter_unformatted in Measured Value Field 6

Display a MVF field (unformatted).

File

./mvf.module, line 665
Measured Value Field module.

Code

function theme_mvf_formatter_unformatted($element) {
  $value = isset($element['#item']['value']) ? $element['#item']['value'] : NULL;
  $value2 = isset($element['#item']['value2']) ? $element['#item']['value2'] : NULL;
  if (!is_numeric($value)) {
    return '';
  }
  $field = content_fields($element['#field_name'], $element['#type_name']);
  $unit = $element['#item']['unit'];

  // Empty "To" value is stored as equal to the "From" value.
  // We display field as single value if both values are equal.
  if ($value2 != '' && $value2 != $value) {
    $display_mode = $field['widget']['unit_display_mode_range'];
  }
  else {
    $display_mode = $field['widget']['unit_display_mode_single'];
  }

  // Format the whole field based on widget display options.
  return theme('mvf_field', $value, $value2, $unit, $display_mode, ' ');
}