You are here

function views_bulk_operations_form_ahah in Views Bulk Operations (VBO) 6

Generic AHAH callback to manipulate a form.

1 string reference to 'views_bulk_operations_form_ahah'
views_bulk_operations_menu in ./views_bulk_operations.module
Implementation of hook_menu().

File

./views_bulk_operations.module, line 1307
Allows operations to be performed on items selected in a view.

Code

function views_bulk_operations_form_ahah($callback) {
  $form_state = array(
    'submitted' => FALSE,
  );
  $form_build_id = $_POST['form_build_id'];

  // Add the new element to the stored form. Without adding the element to the
  // form, Drupal is not aware of this new elements existence and will not
  // process it. We retreive the cached form, add the element, and resave.
  $form = form_get_cache($form_build_id, $form_state);

  // Invoke the callback that will populate the form.
  $render =& $callback($form, array(
    'values' => $_POST,
  ));
  form_set_cache($form_build_id, $form, $form_state);
  $form += array(
    '#post' => $_POST,
    '#programmed' => FALSE,
  );

  // Rebuild the form.
  $form = form_builder($_POST['form_id'], $form, $form_state);

  // Render the new output.
  $output_html = drupal_render($render);
  $output_js = drupal_get_js();
  print drupal_to_js(array(
    'data' => theme('status_messages') . $output_html . $output_js,
    'status' => TRUE,
  ));
  exit;
}