function DatePreprocess::preprocessDatetimeForm
Prepares variables for datetime form element templates.
The datetime form element serves as a wrapper around the date element type, which creates a date and a time component for a date.
Default template: datetime-form.html.twig.
Parameters
array $variables: An associative array containing:
- element: An associative array containing the properties of the element. Properties used: #title, #value, #options, #description, #required, #attributes.
See also
form_process_datetime()
File
-
core/
lib/ Drupal/ Core/ Datetime/ DatePreprocess.php, line 69
Class
- DatePreprocess
- Preprocess for common/core theme templates.
Namespace
Drupal\Core\DatetimeCode
public function preprocessDatetimeForm(array &$variables) : void {
$element = $variables['element'];
$variables['attributes'] = [];
if (isset($element['#id'])) {
$variables['attributes']['id'] = $element['#id'];
}
if (!empty($element['#attributes']['class'])) {
$variables['attributes']['class'] = (array) $element['#attributes']['class'];
}
$variables['content'] = $element;
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.