diff options
author | Dries Buytaert <dries@buytaert.net> | 2006-01-02 08:35:59 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2006-01-02 08:35:59 +0000 |
commit | 749284633f83fbe44114c17c320bbf18a6b70a2e (patch) | |
tree | a91d669535437e50641cae3685c5b28ef2524928 /includes | |
parent | 034712530c161cbe17f512966837d61466e5eb19 (diff) | |
download | brdo-749284633f83fbe44114c17c320bbf18a6b70a2e.tar.gz brdo-749284633f83fbe44114c17c320bbf18a6b70a2e.tar.bz2 |
- Patch #42057 by hunmonk and chx: made saving user accounts work again.
Diffstat (limited to 'includes')
-rw-r--r-- | includes/form.inc | 37 |
1 files changed, 35 insertions, 2 deletions
diff --git a/includes/form.inc b/includes/form.inc index a31a92427..287c250c6 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -143,7 +143,7 @@ function _form_validate($elements, $form_id = NULL) { // An empty checkbox returns 0, an empty textfield returns '' so we use empty(). // Unfortunately, empty('0') returns TRUE so we need a special check for the '0' string. if ($elements['#required'] && empty($elements['#value']) && $elements['#value'] !== '0') { - form_error($elements, t('%name field is required', array('%name' => $elements['#title']))); + form_error($elements, t('%name field is required.', array('%name' => $elements['#title']))); } // Add legal choice check if element has #options. @@ -328,7 +328,8 @@ function _form_builder($form_id, $form) { } if (function_exists($form['#after_build']) && !isset($form['#after_build_done'])) { - $form = call_user_func($form['#after_build'], $form, $form_values); + $function = $form['#after_build']; + $form = $function($form, $form_values, $ref); $form['#after_build_done'] = TRUE; } @@ -524,6 +525,38 @@ function theme_radios($element) { } /** + * Format a password_confirm item. + * + * @param $element + * An associative array containing the properties of the element. + * Properties used: title, value, id, required, error. + * @return + * A themed HTML string representing the form item. + */ +function theme_password_confirm($element) { + return theme('form_element', $element['#title'], '<div class="container-inline">'. $element['#children']. '</div>', $element['#description'], $element['#id'], $element['#required'], form_get_error($element)); +} + +/** + * Build password_confirm element. + */ +function password_confirm_after_build($form, $form_values, &$ref) { + if (isset($form_values['pass1'])) { + $pass1 = trim($form_values['pass1']); + $pass2 = trim($form_values['pass2']); + unset($form_values['pass1'], $form_values['pass2']); + if ($pass1 != $pass2) { + form_set_error('pass1', t('The specified passwords do not match.')); + } + elseif ($form['#required'] && !$pass1) { + form_set_error('pass1', t('Password field is required.')); + } + $ref = $pass1; + } + return $form; +} + +/** * Format a date selection element. * * @param $element |