summaryrefslogtreecommitdiff
path: root/includes/form.inc
diff options
context:
space:
mode:
authorSteven Wittens <steven@10.no-reply.drupal.org>2006-04-26 18:12:24 +0000
committerSteven Wittens <steven@10.no-reply.drupal.org>2006-04-26 18:12:24 +0000
commit83e279a7b8b60d93933c526aa99cf9d169ecd27e (patch)
treefddcfae5836fb256c2ee4ffc516a9cf745fd1e3f /includes/form.inc
parentfae7896d4f7dff72a2c8dc387bde956f07390f53 (diff)
downloadbrdo-83e279a7b8b60d93933c526aa99cf9d169ecd27e.tar.gz
brdo-83e279a7b8b60d93933c526aa99cf9d169ecd27e.tar.bz2
#58059: Fix bug with IE not sending form button values when pressing enter.
Diffstat (limited to 'includes/form.inc')
-rw-r--r--includes/form.inc18
1 files changed, 12 insertions, 6 deletions
diff --git a/includes/form.inc b/includes/form.inc
index c87c48221..ea41b572e 100644
--- a/includes/form.inc
+++ b/includes/form.inc
@@ -59,9 +59,10 @@ function element_children($element) {
*
*/
function drupal_get_form($form_id, &$form, $callback = NULL) {
- global $form_values, $form_submitted, $user;
+ global $form_values, $form_submitted, $user, $form_button_counter;
$form_values = array();
$form_submitted = FALSE;
+ $form_button_counter = array(0, 0);
$form['#type'] = 'form';
if (isset($form['#token'])) {
@@ -114,7 +115,10 @@ function drupal_get_form($form_id, &$form, $callback = NULL) {
$form = form_builder($form_id, $form);
if (!empty($_POST['edit']) && (($_POST['edit']['form_id'] == $form_id) || ($_POST['edit']['form_id'] == $callback))) {
drupal_validate_form($form_id, $form, $callback);
- if ($form_submitted && !form_get_errors()) {
+ // IE does not send a button value when there is only one submit button (and no non-submit buttons)
+ // and you submit by pressing enter.
+ // In that case we accept a submission without button values.
+ if (($form_submitted || (!$form_button_counter[0] && $form_button_counter[1])) && !form_get_errors()) {
$redirect = drupal_submit_form($form_id, $form, $callback);
if (isset($redirect)) {
$goto = $redirect;
@@ -312,8 +316,7 @@ function form_error(&$element, $message = '') {
* An associative array containing the structure of the form.
*/
function form_builder($form_id, $form) {
- global $form_values;
- global $form_submitted;
+ global $form_values, $form_submitted, $form_button_counter;
/* Use element defaults */
if ((!empty($form['#type'])) && ($info = _element_info($form['#type']))) {
@@ -375,8 +378,11 @@ function form_builder($form_id, $form) {
}
}
}
- if (isset($form['#executes_submit_callback']) && isset($_POST[$form['#name']])) {
- if ($_POST[$form['#name']] == $form['#value']) {
+ if (isset($form['#executes_submit_callback'])) {
+ // Count submit and non-submit buttons
+ $form_button_counter[$form['#executes_submit_callback']]++;
+ // See if a submit button was pressed
+ if (isset($_POST[$form['#name']]) && $_POST[$form['#name']] == $form['#value']) {
$form_submitted = $form_submitted || $form['#executes_submit_callback'];
}
}