function webform_preprocess_datetime_form in Webform 6.x
Same name and namespace in other branches
- 8.5 includes/webform.theme.inc \webform_preprocess_datetime_form()
Implements hook_preprocess_datetime_form() for datetime form element templates.
File
- includes/
webform.theme.inc, line 382 - Theme hooks, preprocessor, and suggestions.
Code
function webform_preprocess_datetime_form(&$variables) {
if (!WebformElementHelper::isWebformElement($variables['element'])) {
return;
}
$element = $variables['element'];
// Date and time custom placeholder.
if (isset($element['#date_date_placeholder']) && isset($variables['content']['date'])) {
$variables['content']['date']['#attributes']['placeholder'] = $element['#date_date_placeholder'];
}
if (isset($element['#date_time_placeholder']) && isset($variables['content']['time'])) {
$variables['content']['time']['#attributes']['placeholder'] = $element['#date_time_placeholder'];
}
// Add .container-inline to datetime form wrapper which is missing from the
// stable base theme.
// @see core/themes/classy/templates/form/datetime-form.html.twig
// @see core/themes/stable/templates/form/datetime-form.html.twig
$variables['attributes']['class'][] = 'container-inline';
}