You are here

function dialog_form_wrapper in Dialog 6

Wrap a form so that we can use it properly with AJAX. Essentially if the form wishes to render, it automatically does that, otherwise it returns so we can see submission results.

Return value

The output of the form, if it was rendered. If $form_state['ajax'] is set, this will use ctools_modal_form_render so it will be a $command object suitable for ctools_ajax_render already.

The return will be NULL if the form was successfully submitted unless you specifically set re_render = TRUE. If ajax is set the form will never be redirected.

5 calls to dialog_form_wrapper()
dialog_comment_delete in modules/dialog_comment/dialog_comment.module
Menu page callback for comment/%ctools_js/delete/%
dialog_comment_edit in modules/dialog_comment/dialog_comment.module
Menu page callback for comment/%ctools_js/edit/%
dialog_comment_reply in modules/dialog_comment/dialog_comment.module
Menu page callback for comment/%ctools_js/reply/%node
dialog_get_form in ./dialog.module
Generic dialog replacement for drupal_get_form(). Suitable for use as the page callback in a menu item.
dialog_login_callback in example/dialog_example.module
Menu callback for our ajax links.

File

./dialog.module, line 138

Code

function dialog_form_wrapper($form_id, &$form_state) {
  ctools_include('form');

  // This won't override settings already in.
  $form_state += array(
    're_render' => FALSE,
    'no_redirect' => !empty($form_state['ajax']),
  );
  $output = ctools_build_form($form_id, $form_state);
  if (!empty($form_state['ajax']) && empty($form_state['executed'])) {
    return dialog_form_render($form_state, $output);
  }
  return $output;
}