You are here

function ctools_modal_form_wrapper in Chaos Tool Suite (ctools) 6

Same name and namespace in other branches
  1. 7 includes/modal.inc \ctools_modal_form_wrapper()

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 ctools_modal_form_wrapper()
ctools_access_ajax_add in includes/context-access-admin.inc
AJAX callback to add a new access test to the list.
ctools_access_ajax_edit in includes/context-access-admin.inc
AJAX callback to edit an access test in the list.
ctools_ajax_sample_login in ctools_ajax_sample/ctools_ajax_sample.module
A modal login callback.
ctools_context_ajax_item_add in includes/context-admin.inc
Ajax entry point to add an context
ctools_context_ajax_item_edit in includes/context-admin.inc
Ajax entry point to edit an item

File

includes/modal.inc, line 190
Implement a modal form using AJAX.

Code

function ctools_modal_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']) && (!$form_state['executed'] || $form_state['rebuild'])) {
    return ctools_modal_form_render($form_state, $output);
  }
  return $output;
}