form_get_cache
- Versions
- 6 – 7
form_get_cache($form_build_id, &$form_state)
Fetch a form from cache.
Related topics
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 