summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
authorDries Buytaert <dries@buytaert.net>2010-07-26 13:07:59 +0000
committerDries Buytaert <dries@buytaert.net>2010-07-26 13:07:59 +0000
commit123bf46c432f290e0cabfbb357c434fc61285b89 (patch)
treeb5f3ad0d0f60ebbfa1219d3f26d24e3b0552b86f /includes
parent803101b589a439d2f489ce267dc432ba13efed0b (diff)
downloadbrdo-123bf46c432f290e0cabfbb357c434fc61285b89.tar.gz
brdo-123bf46c432f290e0cabfbb357c434fc61285b89.tar.bz2
- Patch #827430 by David_Rothstein: drupal_form_submit() no longer works with checkboxes.
Diffstat (limited to 'includes')
-rw-r--r--includes/form.inc16
1 files changed, 15 insertions, 1 deletions
diff --git a/includes/form.inc b/includes/form.inc
index f41cce4a7..9b67da8a3 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -1978,8 +1978,22 @@ function form_type_checkboxes_value($element, $input = FALSE) {
}
return $value;
}
+ elseif (is_array($input)) {
+ // Programmatic form submissions use NULL to indicate that a checkbox
+ // should be unchecked; see drupal_form_submit(). We therefore remove all
+ // NULL elements from the array before constructing the return value, to
+ // simulate the behavior of web browsers (which do not send unchecked
+ // checkboxes to the server at all). This will not affect non-programmatic
+ // form submissions, since a checkbox can never legitimately be NULL.
+ foreach ($input as $key => $value) {
+ if (is_null($value)) {
+ unset($input[$key]);
+ }
+ }
+ return drupal_map_assoc($input);
+ }
else {
- return is_array($input) ? drupal_map_assoc($input) : array();
+ return array();
}
}