You are here

public static function WebformTime::processWebformTime in Webform 8.5

Same name and namespace in other branches
  1. 6.x src/Element/WebformTime.php \Drupal\webform\Element\WebformTime::processWebformTime()

Processes a time webform element.

Parameters

array $element: The webform element to process. Properties used:

  • #time_format: The time format used in PHP formats.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

array $complete_form: The complete webform structure.

Return value

array The processed element.

File

src/Element/WebformTime.php, line 85

Class

WebformTime
Provides a webform element for time selection.

Namespace

Drupal\webform\Element

Code

public static function processWebformTime(&$element, FormStateInterface $form_state, &$complete_form) {

  // Add validate callback.
  $element += [
    '#element_validate' => [],
  ];
  array_unshift($element['#element_validate'], [
    get_called_class(),
    'validateWebformTime',
  ]);
  $element['#attached']['library'][] = 'webform/webform.element.time';
  $element['#attributes']['data-webform-time-format'] = !empty($element['#time_format']) ? $element['#time_format'] : DateFormat::load('html_time')
    ->getPattern();
  return $element;
}