summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-02 03:00:28 +0000
committerAngie Byron <webchick@24967.no-reply.drupal.org>2009-11-02 03:00:28 +0000
commitbfedf56f9d9e41eee879221adeb302fb09c072ac (patch)
tree3153308212f7622b9c62e6515d99cd73f8584574 /includes
parent453569e72190e3c9a510fc00fa215ca88110d51a (diff)
downloadbrdo-bfedf56f9d9e41eee879221adeb302fb09c072ac.tar.gz
brdo-bfedf56f9d9e41eee879221adeb302fb09c072ac.tar.bz2
#582584 by dww, Jacine, and chx: Move required form element marker into its own theme function.
Diffstat (limited to 'includes')
-rw-r--r--includes/common.inc3
-rw-r--r--includes/form.inc23
2 files changed, 25 insertions, 1 deletions
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 = '<div class="' . implode(' ', $class) . '">' . "\n";
- $required = !empty($element['#required']) ? '<span class="form-required" title="' . $t('This field is required.') . '">*</span>' : '';
+ $required = !empty($element['#required']) ? theme('form_required_marker', array('element' => $element)) : '';
if (!empty($element['#title']) && empty($element['#form_element_skip_title'])) {
$title = $element['#title'];
@@ -2798,6 +2798,27 @@ function theme_form_element($variables) {
}
/**
+ * 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 '<span' . drupal_attributes($attributes) . '>*</span>';
+}
+
+/**
* Sets a form element's class attribute.
*
* Adds 'required' and 'error' classes as needed.