Commit 302329be authored by catch's avatar catch

Issue #2152205 by joelpittet, mark.labrecque, Manuel Garcia, pakmanlh,...

Issue #2152205 by joelpittet, mark.labrecque, Manuel Garcia, pakmanlh, steveoliver, hussainweb, shanethehat, jenlampton, kpa, AnythonyR, EVIIILJ, kgoel, Cottser, dsdeiz, hanpersand: Convert theme_date() to #theme input__date
parent 4f086d1f
...@@ -1232,29 +1232,32 @@ function password_confirm_validate($element, &$element_state) { ...@@ -1232,29 +1232,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'. * Supports HTML5 types of 'date', 'datetime', 'datetime-local', and 'time'.
* Falls back to a plain textfield. Used as a sub-element by the datetime * Falls back to a plain textfield. Used as a sub-element by the datetime
* element type. * element type.
* *
* @param array $variables * @param array $element
* An associative array containing: * An associative array containing the properties of the element.
* - element: An associative array containing the properties of the element. * Properties used: #title, #value, #options, #description, #required,
* Properties used: #title, #value, #options, #description, #required, * #attributes, #id, #name, #type, #min, #max, #step, #value, #size.
* #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) { function form_pre_render_date($element) {
$element = $variables['element']; if (empty($element['#attributes']['type'])) {
if (empty($element['attribute']['type'])) { $element['#attributes']['type'] = 'date';
$element['attribute']['type'] = 'date';
} }
Element::setAttributes($element, array('id', 'name', 'type', 'min', 'max', 'step', 'value', 'size')); Element::setAttributes($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 '<input' . new Attribute($element['#attributes']) . ' />'; return $element;
} }
/** /**
......
...@@ -2646,9 +2646,6 @@ function drupal_common_theme() { ...@@ -2646,9 +2646,6 @@ function drupal_common_theme() {
'render element' => 'element', 'render element' => 'element',
'template' => 'radios', 'template' => 'radios',
), ),
'date' => array(
'render element' => 'element',
),
'checkboxes' => array( 'checkboxes' => array(
'render element' => 'element', 'render element' => 'element',
'template' => 'checkboxes', 'template' => 'checkboxes',
......
...@@ -524,7 +524,8 @@ function system_element_info() { ...@@ -524,7 +524,8 @@ function system_element_info() {
); );
$types['date'] = array( $types['date'] = array(
'#input' => TRUE, '#input' => TRUE,
'#theme' => 'date', '#theme' => 'input__date',
'#pre_render' => array('form_pre_render_date'),
'#theme_wrappers' => array('form_element'), '#theme_wrappers' => array('form_element'),
); );
$types['file'] = array( $types['file'] = array(
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment