You are here

function form_set_cache in Drupal 6

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

Store a form in the cache.

Related topics

4 calls to form_set_cache()
book_form_update in modules/book/book.pages.inc
Renders a new parent page select element when the book selection changes.
drupal_get_form in includes/form.inc
Retrieves a form from a constructor function, or from the cache if the form was built in a previous page-load. The form is then passed on for processing, after and rendered for display if necessary.
drupal_rebuild_form in includes/form.inc
Retrieves a form, caches it and processes it with an empty $_POST.
upload_js in modules/upload/upload.module
Menu-callback for JavaScript-based uploads.

File

includes/form.inc, line 221

Code

function form_set_cache($form_build_id, $form, $form_state) {
  global $user;

  // 6 hours cache life time for forms should be plenty.
  $expire = 21600;
  if ($user->uid) {
    $form['#cache_token'] = drupal_get_token();
  }
  elseif (variable_get('cache', CACHE_DISABLED) != CACHE_DISABLED && $_SERVER['REQUEST_METHOD'] == 'GET' && page_get_cache(TRUE)) {
    $form['#immutable'] = TRUE;
  }
  $form_build_id_old = $form_build_id;
  $form_build_id = form_build_id_map($form_build_id_old);
  cache_set('form_' . $form_build_id, $form, 'cache_form', time() + $expire);
  if (!empty($form_state['storage'])) {
    cache_set('storage_' . $form_build_id, $form_state['storage'], 'cache_form', time() + $expire);
  }

  // If form_set_cache is called in the context of an ahah handler inform the
  // client about the changed form build_id via the X-Drupal-Build-Id HTTP
  // header.
  if (!empty($_SERVER['HTTP_X_DRUPAL_ACCEPT_BUILD_ID']) && !empty($_POST['form_build_id']) && $_POST['form_build_id'] == $form_build_id_old && $form_build_id_old != $form_build_id) {
    drupal_set_header('X-Drupal-Build-Id: ' . $form_build_id);
  }
}