function views_ui_ajax_get_form

Menu callback.

Handles AJAX form submissions similar to ajax_form_callback(), but can be used for uncached forms.

Ajax_form_callback(), the menu callback for the system/ajax path, requires the form to be retrievable from the form cache, because it lacks a trusted $form_id argument with which to call drupal_retrieve_form(). When AJAX is wanted on a non-cacheable form, #ajax['path'] can be set to a path whose menu router item's 'page callback' is this function, and whose 'page arguments' is the form id, optionally followed by additional build arguments, as expected by drupal_get_form().

The same caution must be used when defining a hook_menu() entry with this page callback as is used when defining a hook_menu() entry with the 'drupal_get_form' page callback: a 'page arguments' must be specified with a literal value as the first argument, because $form_id determines which form builder function gets called, so must be safe from user tampering.

See also

drupal_get_form()

ajax_form_callback()

http://drupal.org/node/774876

1 string reference to 'views_ui_ajax_get_form'
views_ui_menu in ./views_ui.module
Implements hook_menu().

File

./views_ui.module, line 807

Code

function views_ui_ajax_get_form($form_id) {
    $args = func_get_args();
    array_shift($args);
    // @see ajax_get_form()
    $form_state = array(
        'no_redirect' => TRUE,
    );
    $form_state['rebuild_info']['copy']['#build_id'] = TRUE;
    $form_state['rebuild_info']['copy']['#action'] = TRUE;
    // @see drupal_get_form()
    $form_state['build_info']['args'] = $args;
    $form = drupal_build_form($form_id, $form_state);
    // @see ajax_form_callback()
    if (!empty($form_state['triggering_element'])) {
        $callback = $form_state['triggering_element']['#ajax']['callback'];
    }
    if (!empty($callback) && function_exists($callback)) {
        return $callback($form, $form_state);
    }
}