Index: form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.265.2.1 diff -u -r1.265.2.1 form.inc --- form.inc 4 Feb 2008 16:24:29 -0000 1.265.2.1 +++ form.inc 5 Feb 2008 16:03:39 -0000 @@ -664,11 +664,14 @@ // Validate the current input. if (!isset($elements['#validated']) || !$elements['#validated']) { if (isset($elements['#needs_validation'])) { - // An empty textfield returns '' so we use empty(). An empty checkbox - // and a textfield could return '0' and 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']))); + // Make sure a value is passed when the field is required. + if ($elements['#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 (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0)) { + form_error($elements, $t('!name field is required.', array('!name' => $elements['#title']))); + } } // Verify that the value is not longer than #maxlength.