_form_button_was_clicked
includes/form.inc, строка 1066
- Версии
- 6
_form_button_was_clicked($form)
Helper function to handle the sometimes-convoluted logic of button click detection.
In Internet Explorer, if ONLY one submit button is present, AND the
enter key is used to submit the form, no form value is sent for it
and we'll never detect a match. That special case is handled by
_form_builder_ie_cleanup()
.
Связанные темы
Код
<?php
function _form_button_was_clicked($form) {
// First detect normal 'vanilla' button clicks. Traditionally, all
// standard buttons on a form share the same name (usually 'op'),
// and the specific return value is used to determine which was
// clicked. This ONLY works as long as $form['#name'] puts the
// value at the top level of the tree of $_POST data.
if (isset($form['#post'][$form['#name']]) && $form['#post'][$form['#name']] == $form['#value']) {
return TRUE;
}
// When image buttons are clicked, browsers do NOT pass the form element
// value in $_POST. Instead they pass an integer representing the
// coordinates of the click on the button image. This means that image
// buttons MUST have unique $form['#name'] values, but the details of
// their $_POST data should be ignored.
elseif (!empty($form['#has_garbage_value']) && isset($form['#value']) && $form['#value'] !== '') {
return TRUE;
}
return FALSE;
}
?>
Войдите или зарегистрируйтесь, чтобы получить возможность отправлять комментарии