Search code examples
phpdrupaldrupal-6drupal-fapi

Why would a Drupal form not be cached in cache_form?


My form, lets call it organize_issue, is a form in a custom module being called from the menu using the page callback drupal_get_form function. The form works perfectly well.

I'm trying to implement some AHAH type functionality now, and need to get the page from cache using form_get_cache($form_build_id, $form_state) but, oddly enough, my form isn't being cached. Ever. Other forms on the site are, just not this one. As I said the form works fine, and submits and validates and whatnot... it just never caches. Is their something simple I'm missing?


Solution

  • In your function that builds the form you should have a value setting the form to cache...

    Should look some thing like '#cache' => TRUE, if you don't see it that might be why your form isn't caching...you should be building your form on a way that the array of the form sets it to cache:

    <?php
      function _organize_issue_form($node) {
        global $user;
    
     $form = array(
       '#theme' => 'organize_issue',
       '#cache' => TRUE,
     );
    ?>
    

    HTH