You are here

function hms_field_field_widget_form in HMS Field 7

Implements hook_field_widget_form().

File

./hms_field.module, line 103
Provides an hms_field functionality.

Code

function hms_field_field_widget_form(&$form, &$form_state, $field, $instance, $langcode, $items, $delta, $element) {
  $value = isset($items[$delta]['value']) ? $items[$delta]['value'] : NULL;
  $format = $instance['settings']['format'];
  $default_description = $instance['settings']['default_description'];
  $widget = $element;
  $widget['#delta'] = $delta;
  $widget += array(
    '#type' => 'hms',
    '#default_value' => $value,
    '#format' => $format,
  );
  if ($default_description && (!isset($widget['#description']) || !strlen($widget['#description']))) {
    $widget['#description'] = t('Input format: @format. Decimal number can be used separated with dot (e.g. 0,25 = 15 minutes)', array(
      '@format' => $format,
    ));
  }
  $element['value'] = $widget;
  return $element;
}