From 66c79ee7922cc9ca4f5cdaeb0222c392e8b00571 Mon Sep 17 00:00:00 2001 From: Dries Buytaert Date: Sat, 15 Mar 2008 11:02:47 +0000 Subject: - Patch #117748 by pwolanin: made account creation work again. --- includes/form.inc | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'includes') 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']))); } -- cgit v1.2.3