Index: computed_field.module =================================================================== --- computed_field.module (revision 590) +++ computed_field.module (working copy) @@ -12,6 +12,7 @@ 'code' => '$entity_field[0][\'value\'] = "";', 'display_format' => '$display_output = $entity_field_item[\'value\'];', 'store' => 1, + 'recalculate' => 0, 'database' => array( 'data_type' => 'varchar', 'data_length' => 32, @@ -102,6 +103,11 @@ '#markup' => t('This field is DISPLAYED using @display_func().', array('@display_func' => $display_func)), ); } + $form['recalculate'] = array( + '#type' => 'checkbox', + '#title' => t('Recalculate the field value every time.'), + '#description' => t('By default, Drupal will cache the value of this field even if it is not stored in the database (and even if Page Caching is disabled). This option will cause computed_field to recalculate the value every time this field is displayed. For example, a time-based calculated value may change more often than field cache is cleared. (Note that Drupal page caching will still cache the field value.)'), + '#default_value' => empty($settings['recalculate']) ? 0 : $settings['recalculate'], ); $form['store'] = array( '#type' => 'checkbox', @@ -222,7 +228,8 @@ $settings = $field['settings']; // Compute field values in case user is "previewing" an entity foreach ($entities as $etid => $entity) { - if (isset($entity->op) && $entity->op == 'Preview') { + if ((isset($entity->op) && $entity->op == 'Preview') || !empty($settings['recalculate'])) { +dpm(__LINE__); _computed_field_compute_value($entity_type, $entity, $field, $instances, $langcode, $items[$etid]); } }