From bfedf56f9d9e41eee879221adeb302fb09c072ac Mon Sep 17 00:00:00 2001 From: Angie Byron Date: Mon, 2 Nov 2009 03:00:28 +0000 Subject: #582584 by dww, Jacine, and chx: Move required form element marker into its own theme function. --- includes/common.inc | 3 +++ includes/form.inc | 23 ++++++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) (limited to 'includes') diff --git a/includes/common.inc b/includes/common.inc index ce76725cf..fc1e71d29 100644 --- a/includes/common.inc +++ b/includes/common.inc @@ -5321,6 +5321,9 @@ function drupal_common_theme() { 'form_element' => array( 'render element' => 'element', ), + 'form_required_marker' => array( + 'arguments' => array('element' => NULL), + ), 'text_format_wrapper' => array( 'render element' => 'element', ), diff --git a/includes/form.inc b/includes/form.inc index 06ab7e0a6..5e3895aaa 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -2774,7 +2774,7 @@ function theme_form_element($variables) { } $output = '
' . "\n"; - $required = !empty($element['#required']) ? '*' : ''; + $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : ''; if (!empty($element['#title']) && empty($element['#form_element_skip_title'])) { $title = $element['#title']; @@ -2797,6 +2797,27 @@ function theme_form_element($variables) { return $output; } +/** + * Theme the marker for required form elements. + * + * @param $variables + * An associative array containing: + * - element: An associative array containing the properties of the element. + * @return + * A string representing the marker to identify required form elements. + * + * @ingroup themeable + */ +function theme_form_required_marker($variables) { + // This is also used in the installer, pre-database setup. + $t = get_t(); + $attributes = array( + 'class' => 'form-required', + 'title' => $t('This field is required.'), + ); + return '*'; +} + /** * Sets a form element's class attribute. * -- cgit v1.2.3