You are here

function _webform_submission_display_time in Webform 5.2

Same name and namespace in other branches
  1. 5 components/time.inc \_webform_submission_display_time()
  2. 6.2 components/time.inc \_webform_submission_display_time()

Display the result of a textfield submission. The output of this function will be displayed under the "results" tab then "submissions".

Parameters

$data: An array of information containing the submission result, directly correlating to the webform_submitted_data database schema.

$component: An array of information describing the component, directly correlating to the webform_component database schema.

$enabled: If enabled, the value may be changed. Otherwise it will set to readonly.

Return value

Textual output formatted for human reading.

File

components/time.inc, line 198
Webform module time component.

Code

function _webform_submission_display_time($data, $component, $enabled = FALSE) {
  $form_item = _webform_render_time($component);
  $form_item['minute']['#default_value'] = $data['value']['1'];
  $form_item['minute']['#disabled'] = !$enabled;
  $form_item['hour']['#disabled'] = !$enabled;
  $form_item['ampm']['#disabled'] = !$enabled;

  // Match the hourly data to the hour format.
  if ($data['value']['1']) {
    $timestamp = strtotime($data['value']['0'] . ':' . $data['value']['1'] . (isset($data['value']['2']) ? $data['value']['2'] : ''));
    if ($component['extra']['hourformat'] == '24-hour') {
      $form_item['hour']['#default_value'] = date('H', $timestamp);
    }
    else {
      $form_item['hour']['#default_value'] = date('g', $timestamp);
      $form_item['ampm']['#default_value'] = $data['value']['2'];
    }
  }
  return $form_item;
}