form_get_cache

Versions
6 – 7
form_get_cache($form_build_id, &$form_state)

Fetch a form from cache.

Related topics

▾ 3 functions call form_get_cache()

ajax_get_form in includes/ajax.inc
Get a form submitted via #ajax during an AJAX callback.
drupal_build_form in includes/form.inc
Build and process a form based on a form id.
upload_js in modules/upload/upload.module
Menu-callback for JavaScript-based uploads.

Code

includes/form.inc, line 346

<?php
function form_get_cache($form_build_id, &$form_state) {
  if ($cached = cache_get('form_' . $form_build_id, 'cache_form')) {
    $form = $cached->data;

    global $user;
    if ((isset($form['#cache_token']) && drupal_valid_token($form['#cache_token'])) || (!isset($form['#cache_token']) && !$user->uid)) {
      if ($cached = cache_get('form_state_' . $form_build_id, 'cache_form')) {
        // Re-populate $form_state for subsequent rebuilds.
        $form_state['build_info'] = $cached->data['build_info'];
        $form_state['storage'] = $cached->data['storage'];

        // If the original form is contained in an include file, load the file.
        // @see drupal_build_form()
        if (!empty($form_state['build_info']['file']) && file_exists($form_state['build_info']['file'])) {
          require_once DRUPAL_ROOT . '/' . $form_state['build_info']['file'];
        }
      }
      return $form;
    }
  }
}
?>
Login or register to post comments
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.