diff --git a/core/includes/form.inc b/core/includes/form.inc index 8f03f77..cc190e1 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -1194,29 +1194,32 @@ function password_confirm_validate($element, &$element_state) { } /** - * Returns HTML for an #date form element. + * Adds form-specific attributes to a 'date' #type element. * * Supports HTML5 types of 'date', 'datetime', 'datetime-local', and 'time'. * Falls back to a plain textfield. Used as a sub-element by the datetime * element type. * - * @param array $variables - * An associative array containing: - * - element: An associative array containing the properties of the element. - * Properties used: #title, #value, #options, #description, #required, - * #attributes, #id, #name, #type, #min, #max, #step, #value, #size. + * @param array $element + * An associative array containing the properties of the element. + * Properties used: #title, #value, #options, #description, #required, + * #attributes, #id, #name, #type, #min, #max, #step, #value, #size. * - * @ingroup themeable + * Note: The input "name" attribute needs to be sanitized before output, which + * is currently done by initializing Drupal\Core\Template\Attribute with + * all the attributes. + * + * @return array + * The $element with prepared variables ready for #theme 'input__date'. */ -function theme_date($variables) { - $element = $variables['element']; - if (empty($element['attribute']['type'])) { - $element['attribute']['type'] = 'date'; +function form_pre_render_date($element) { + if (empty($element['#attributes']['type'])) { + $element['#attributes']['type'] = 'date'; } element_set_attributes($element, array('id', 'name', 'type', 'min', 'max', 'step', 'value', 'size')); - _form_set_attributes($element, array('form-' . $element['attribute']['type'])); + _form_set_attributes($element, array('form-' . $element['#attributes']['type'])); - return ''; + return $element; } /** diff --git a/core/includes/theme.inc b/core/includes/theme.inc index f98df80..9939856 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -2879,9 +2879,6 @@ function drupal_common_theme() { 'render element' => 'element', 'template' => 'radios', ), - 'date' => array( - 'render element' => 'element', - ), 'checkboxes' => array( 'render element' => 'element', ), diff --git a/core/modules/system/system.module b/core/modules/system/system.module index b746d01..224e6b2 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -520,7 +520,8 @@ function system_element_info() { ); $types['date'] = array( '#input' => TRUE, - '#theme' => 'date', + '#theme' => 'input__date', + '#pre_render' => array('form_pre_render_date'), '#theme_wrappers' => array('form_element'), ); $types['file'] = array(