You are here

public static function YamlFormTime::processYamlFormTime in YAML Form 8

Processes a time form element.

Parameters

array $element: The form 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 form structure.

Return value

array The processed element.

File

src/Element/YamlFormTime.php, line 73

Class

YamlFormTime
Provides a form element for time selection.

Namespace

Drupal\yamlform\Element

Code

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

  // Attach JS support for the time field, if we can determine which time
  // format should be used.
  if (!empty($element['#time_format'])) {
    $element['#attached']['library'][] = 'yamlform/yamlform.element.time';
    $element['#attributes']['data-yamlform-time-format'] = [
      $element['#time_format'],
    ];
  }
  return $element;
}