diff options
author | Dries Buytaert <dries@buytaert.net> | 2008-03-15 11:02:47 +0000 |
---|---|---|
committer | Dries Buytaert <dries@buytaert.net> | 2008-03-15 11:02:47 +0000 |
commit | 66c79ee7922cc9ca4f5cdaeb0222c392e8b00571 (patch) | |
tree | 3d74dcaf2f36c38e0d1f3a4f9ce63292106edcd5 | |
parent | 39f1a6be73a088f2d587485f10d2788613830a89 (diff) | |
download | brdo-66c79ee7922cc9ca4f5cdaeb0222c392e8b00571.tar.gz brdo-66c79ee7922cc9ca4f5cdaeb0222c392e8b00571.tar.bz2 |
- Patch #117748 by pwolanin: made account creation work again.
-rw-r--r-- | includes/form.inc | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/includes/form.inc b/includes/form.inc index eb9434338..c7738d029 100644 --- a/includes/form.inc +++ b/includes/form.inc @@ -664,10 +664,11 @@ function _form_validate($elements, &$form_state, $form_id = NULL) { // Validate the current input. if (!isset($elements['#validated']) || !$elements['#validated']) { if (isset($elements['#needs_validation'])) { - // We only check for trimmed string length being zero. 0 might be - // a possible value with some field types, such as radio buttons, so - // empty() is not usable here. - if ($elements['#required'] && strlen(trim($elements['#value'])) == 0) { + // Make sure a value is passed when the field is required. + // A simple call to empty() will not cut it here as some fields, like + // checkboxes, can return a valid value of '0'. Instead, check the + // length if it's a string, and the item count if it's an array. + if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) { form_error($elements, $t('!name field is required.', array('!name' => $elements['#title']))); } |