Index: includes/form.inc =================================================================== RCS file: /cvs/drupal/drupal/includes/form.inc,v retrieving revision 1.400 diff -u -p -r1.400 form.inc --- includes/form.inc 16 Nov 2009 05:11:01 -0000 1.400 +++ includes/form.inc 16 Nov 2009 15:26:40 -0000 @@ -831,9 +831,9 @@ function _form_validate($elements, &$for // 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. - // An unchecked checkbox has a #value of numeric 0, different than string - // '0', which could be a valid value. - if ($elements['#required'] && (!count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0) || $elements['#value'] === 0)) { + // Unchecked checkboxes have a #value of NULL; see + // form_type_checkbox_value(). + if ($elements['#required'] && (!isset($elements['#value']) || !count($elements['#value']) || (is_string($elements['#value']) && strlen(trim($elements['#value'])) == 0))) { form_error($elements, $t('!name field is required.', array('!name' => $elements['#title']))); } @@ -1417,9 +1417,9 @@ function form_type_checkbox_value($eleme if (empty($element['#disabled'])) { // Successful (checked) checkboxes are present with a value (possibly '0'). // http://www.w3.org/TR/html401/interact/forms.html#successful-controls - // For an unchecked checkbox, we return numeric 0, so we can explicitly - // test for a value different than string '0'. - return isset($input) ? $element['#return_value'] : 0; + // For an unchecked checkbox, we return NULL, so we can explicitly + // test for a value. + return isset($input) ? $element['#return_value'] : NULL; } else { // Disabled form controls are not submitted by the browser. Ignore any @@ -2133,7 +2133,7 @@ function theme_checkbox($variables) { $checkbox .= 'id="' . $element['#id'] . '" ' ; $checkbox .= 'value="' . $element['#return_value'] . '" '; // Unchecked checkbox has #value of numeric 0. - if ($element['#value'] !== 0 && $element['#value'] == $element['#return_value']) { + if ($element['#value'] === $element['#return_value']) { $checkbox .= 'checked="checked" '; } $checkbox .= drupal_attributes($element['#attributes']) . ' />';