form_set_cache

  1. drupal
    1. 6
    2. 8
    3. 7
Versions
6 – 7 form_set_cache($form_build_id, $form, $form_state)

Store a form in the cache.

Related topics

▾ 2 functions call form_set_cache()

drupal_process_form in includes/form.inc
Processes a form submission.
drupal_rebuild_form in includes/form.inc
Constructs a new $form from the information in $form_state.

Code

includes/form.inc, line 517

<?php
function form_set_cache($form_build_id, $form, $form_state) {
  // 6 hours cache life time for forms should be plenty.
  $expire = 21600;

  // Cache form structure.
  if (isset($form)) {
    if ($GLOBALS['user']->uid) {
      $form['#cache_token'] = drupal_get_token();
    }
    cache_set('form_' . $form_build_id, $form, 'cache_form', REQUEST_TIME + $expire);
  }

  // Cache form state.
  if ($data = array_diff_key($form_state, array_flip(form_state_keys_no_cache()))) {
    cache_set('form_state_' . $form_build_id, $data, 'cache_form', REQUEST_TIME + $expire);
  }
}
?>