summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2004-10-13 17:21:06 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2004-10-13 17:21:06 +0000
commitb3451d0274dcae62f72e594747278ab19697afe5 (patch)
treea5f670aab156ac636addee37b01a791d78575781
parent0261efc8fd547ddcbba77de6bc7e8fb170b1ae59 (diff)
downloadbrdo-b3451d0274dcae62f72e594747278ab19697afe5.tar.gz
brdo-b3451d0274dcae62f72e594747278ab19697afe5.tar.bz2
Adding a note about the usage of form_hidden inside form_checkbox and form_checkboxes.
-rw-r--r--includes/common.inc5
1 files changed, 5 insertions, 0 deletions
diff --git a/includes/common.inc b/includes/common.inc
index 066e1840a..1984796c9 100644
--- a/includes/common.inc
+++ b/includes/common.inc
@@ -1240,6 +1240,8 @@ function form_checkbox($title, $name, $value = 1, $checked = FALSE, $description
if (!is_null($title)) {
$element = '<label class="option">'. $element .' '. $title .'</label>';
}
+ // Note: because unchecked boxes are not included in the POST data, we include
+ // a form_hidden() which will be overwritten for a checked box.
return form_hidden($name, 0) . theme('form_element', NULL, $element, $description, $name, $required, _form_get_error($name));
}
@@ -1273,6 +1275,9 @@ function form_checkboxes($title, $name, $values, $options, $description = NULL,
foreach ($options as $key => $choice) {
$choices .= '<label class="option"><input type="checkbox" class="form-checkbox" name="edit['. $name .'][]" value="'. $key .'"'. (in_array($key, $values) ? ' checked="checked"' : ''). drupal_attributes($attributes). ' /> '. $choice .'</label><br />';
}
+ // Note: because unchecked boxes are not included in the POST data, we
+ // include a form_hidden() which will be overwritten as soon as there is at
+ // least one checked box.
return form_hidden($name, 0) . theme('form_element', $title, $choices, $description, NULL, $required, _form_get_error($name));
}
}