You are here

function modalframe_form_after_build in Modal Frame API 6

Same name and namespace in other branches
  1. 7 modalframe.module \modalframe_form_after_build()

Form after build callback.

Ok, all hook_form_alter() have been processed. Now, if someone has enabled the global variable $GLOBALS['modalframe_page_template'], then we want to scan the form structure in search of elements with submit handlers.

See also

_form_builder_handle_input_element()

_form_builder_ie_cleanup()

form_execute_handlers()

form_builder()

1 string reference to 'modalframe_form_after_build'
modalframe_form_alter in ./modalframe.module
Implementation of hook_form_alter().

File

./modalframe.module, line 155
Provides an API to render an iframe within a modal dialog based on the jQuery UI Dialog plugin.

Code

function modalframe_form_after_build($form, &$form_state) {
  if (!empty($GLOBALS['modalframe_page_template'])) {

    // Form API may have already captured submit handlers from the submitted
    // button before after_build callback is invoked. This may have been done
    // by _form_builder_handle_input_element().
    // If so, the list of submit handlers is stored in the $form_state array
    // which is something we can also alter from here, luckily. :)
    // Remember: our goal here is to make sure $form_state['redirect'] is set
    // to FALSE when the modalframe_close_dialog() API is invoked, and that's
    // because we want to tell the parent window to close the modal frame.
    if (!empty($form_state['submit_handlers']) && !in_array('modalframe_form_submit', $form_state['submit_handlers'])) {
      $form_state['submit_handlers'][] = 'modalframe_form_submit';
    }

    // Find form elements with submit handlers recursively.
    modalframe_form_after_build_recursive($form, $form_state);
  }
  return $form;
}