diff --git a/core/includes/form.inc b/core/includes/form.inc index 0ef70f8..08e70cc 100644 --- a/core/includes/form.inc +++ b/core/includes/form.inc @@ -3190,6 +3190,63 @@ function theme_checkbox($variables) { } /** + * Returns HTML for an input form element. + * + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * + * @ingroup themeable + */ +function theme_input($variables) { + $element = $variables['element']; + return ''; +} + +/** + * Preprocess variables for input form element templates. + * + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * + * @ingroup themeable + */ +function template_preprocess_input(&$variables) { + $element = $variables['element']; + $variables['theme_hook_suggestions'][] = 'input__' . $element['#type']; + $variables['attributes'] = new Attribute($element['#attributes']); +} + +/** + * Preprocess variables for checkbox input form elements. + * + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * Properties used: #title, #value, #return_value, #description, #required, + * #attributes, #checked. + * + * @ingroup themeable + */ +function template_preprocess_input__checkbox(&$variables) { + $element = $variables['element']; + $t = get_t(); + $element['#attributes']['type'] = 'checkbox'; + element_set_attributes($element, array('id', 'name', '#return_value' => 'value')); + + // Unchecked checkbox has #value of integer 0. + if (!empty($element['#checked'])) { + $element['#attributes']['checked'] = 'checked'; + } + _form_set_attributes($element, array('form-checkbox')); + + $element['#attributes']['input-type'] = 'checkbox'; + + $variables['attributes'] = new Attribute($element['#attributes']); +} + +/** * Returns HTML for a set of checkbox form elements. * * @param $variables diff --git a/core/includes/theme.inc b/core/includes/theme.inc index 35b9cd3..3c4a3d0 100644 --- a/core/includes/theme.inc +++ b/core/includes/theme.inc @@ -3244,6 +3244,9 @@ function drupal_common_theme() { 'variables' => array('primary' => array(), 'secondary' => array()), ), // From form.inc. + 'input' => array( + 'render element' => 'element', + ), 'select' => array( 'render element' => 'element', ), diff --git a/core/modules/system/system.module b/core/modules/system/system.module index 6dd33b1..0cf4b5c 100644 --- a/core/modules/system/system.module +++ b/core/modules/system/system.module @@ -445,7 +445,7 @@ function system_element_info() { $types['checkbox'] = array( '#input' => TRUE, '#return_value' => 1, - '#theme' => 'checkbox', + '#theme' => 'input__checkbox', '#process' => array('form_process_checkbox', 'ajax_process_form'), '#theme_wrappers' => array('form_element'), '#title_display' => 'after', diff --git a/core/themes/stark/templates/form.inc/input--checkbox.tpl.php b/core/themes/stark/templates/form.inc/input--checkbox.tpl.php new file mode 100644 index 0000000..6616c0e --- /dev/null +++ b/core/themes/stark/templates/form.inc/input--checkbox.tpl.php @@ -0,0 +1,21 @@ +input--checkbox.tpl: +/> + diff --git a/core/themes/stark/templates/form.inc/input.tpl.php b/core/themes/stark/templates/form.inc/input.tpl.php new file mode 100644 index 0000000..d59cf68 --- /dev/null +++ b/core/themes/stark/templates/form.inc/input.tpl.php @@ -0,0 +1,36 @@ +input.tpl: +/> +