_form_builder_ie_cleanup
- Versions
- 6 – 7
_form_builder_ie_cleanup($form, &$form_state)
In IE, 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 our normal button detection code will never detect a match. We call this function after all other button-detection is complete to check for the proper conditions, and treat the single button on the form as 'clicked' if they are met.
Related topics
Code
includes/form.inc, line 1100
<?php
function _form_builder_ie_cleanup($form, &$form_state) {
// Quick check to make sure we're always looking at the full form
// and not a sub-element.
if (!empty($form['#type']) && $form['#type'] == 'form') {
// If we haven't recognized a submission yet, and there's a single
// submit button, we know that we've hit the right conditions. Grab
// the first one and treat it as the clicked button.
if (empty($form_state['submitted']) && !empty($form_state['buttons']['submit']) && empty($form_state['buttons']['button'])) {
$button = $form_state['buttons']['submit'][0];
// Set up all the $form_state information that would have been
// populated had the button been recognized earlier.
$form_state['submitted'] = TRUE;
$form_state['submit_handlers'] = empty($button['#submit']) ? NULL : $button['#submit'];
$form_state['validate_handlers'] = empty($button['#validate']) ? NULL : $button['#validate'];
$form_state['values'][$button['#name']] = $button['#value'];
$form_state['clicked_button'] = $button;
}
}
}
?>Login or register to post comments 