You are here

function office_hours_handler_filter_hours::value_form in Office Hours 7

Same name and namespace in other branches
  1. 6.2 includes/office_hours_handler_filter_hours.inc \office_hours_handler_filter_hours::value_form()
  2. 6 includes/office_hours_handler_filter_hours.inc \office_hours_handler_filter_hours::value_form()

Provide a select list for times.

Overrides views_handler_filter_numeric::value_form

File

includes/office_hours_handler_filter_hours.inc, line 19
Implements Views integration: hours filter

Class

office_hours_handler_filter_hours
Adds an hours handler to the filter.

Code

function value_form(&$form, &$form_state) {
  parent::value_form($form, $form_state);
  $field = field_info_field($this->real_field);

  // Get the valid hours. Date API doesn't provide a straight method for this.
  // TODO: add better selection and representation of hours,
  // using $field['settings'] and using/improving existing routines.

  //$hours = _office_hours_field_widget_hours($field['settings']);

  //$hours = drupal_map_assoc($hours); // $key == $value.
  $hours = _office_hours_show_ampm(date_hours('H', FALSE));
  $hours = drupal_map_assoc($hours);

  // $key == $value.
  // Make al text fields a select field.
  $hour_select = array(
    '#type' => 'select',
    '#size' => NULL,
    '#options' => $hours,
  );

  // if ($which == 'all').
  if (is_array($form['value']['value'])) {
    $form['value']['value'] = $hour_select + $form['value']['value'];
  }
  elseif ($form['value']['#type'] == 'textfield') {
    $form['value'] = $hour_select + $form['value'];
  }

  // if ($which == 'all' || $which == 'minmax').
  if (is_array($form['value']['min'])) {
    $form['value']['min'] = $hour_select + $form['value']['min'];
  }
  if (is_array($form['value']['max'])) {
    $form['value']['max'] = $hour_select + $form['value']['max'];
  }
}