You are here

function _office_hours_select_process in Office Hours 7

Process the office_hours_select element.

1 string reference to '_office_hours_select_process'
office_hours_element_info in ./office_hours.module
Implements FAPI hook_element_info().

File

includes/office_hours.elements.inc, line 120
Office hours form elements and their theming and validation.

Code

function _office_hours_select_process($element, &$form_state, $form) {
  $element['hours'] = array(
    '#type' => 'select',
    '#options' => $element['#field_settings']['#hours'],
    '#default_value' => $element['#value']['hour'],
  );
  $element['minutes'] = array(
    '#type' => 'select',
    '#options' => $element['#field_settings']['#minutes'],
    '#default_value' => $element['#value']['minute'],
  );
  if ($element['#field_settings']['hoursformat'] == 1) {

    // ampm options, taken from date_ampm().
    $options = date_ampm();
    $element['ampm'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $element['#value']['ampm'],
    );
  }
  elseif ($element['#field_settings']['hoursformat'] == 3) {

    // ampm options, taken from date_ampm().
    $none = array(
      '' => '',
    );
    $ampm = array(
      'am' => t('a.m.', array(), array(
        'context' => 'ampm',
      )),
      'pm' => t('p.m.', array(), array(
        'context' => 'ampm',
      )),
    );
    $options = $none + $ampm;
    $element['ampm'] = array(
      '#type' => 'select',
      '#options' => $options,
      '#default_value' => $element['#value']['ampm'],
    );
  }
  return $element;
}