summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--API.txt6
-rw-r--r--ctools.module22
-rw-r--r--includes/wizard.inc8
3 files changed, 31 insertions, 5 deletions
diff --git a/API.txt b/API.txt
index b0db2e2..d1eb582 100644
--- a/API.txt
+++ b/API.txt
@@ -1,10 +1,12 @@
-Current API Version: 2.0.3
+Current API Version: 2.0.4
Please note that the API version is an internal number and does not match release numbers. It is entirely possible that releases will not increase the API version number, and increasing this number too often would burden contrib module maintainers who need to keep up with API changes.
This file contains a log of changes to the API.
+API Version 2.0.4
+ Introduce ctools_form_include_file()
-API Version 2.0.2
+API Version 2.0.3
Introduce ctools_field_invoke_field() and
API Version 2.0.2
diff --git a/ctools.module b/ctools.module
index d8b8d01..eca75f2 100644
--- a/ctools.module
+++ b/ctools.module
@@ -9,7 +9,7 @@
* must be implemented in the module file.
*/
-define('CTOOLS_API_VERSION', '2.0.3');
+define('CTOOLS_API_VERSION', '2.0.4');
/**
* Test the CTools API version.
@@ -122,11 +122,31 @@ function ctools_include($file, $module = 'ctools', $dir = 'includes') {
* the form_state so that cached forms will properly include things.
*/
function ctools_form_include(&$form_state, $file, $module = 'ctools', $dir = 'includes') {
+ if (!isset($form_state['build_info']['args'])) {
+ $form_state['build_info']['args'] = array();
+ }
+
$dir = '/' . ($dir ? $dir . '/' : '');
form_load_include($form_state, 'inc', $module, $dir . $file);
}
/**
+ * Add an arbitrary path to the $form_state so it can work with form cache.
+ *
+ * module_load_include uses an unfortunately annoying syntax to work, making it
+ * difficult to translate the more simple $path + $file syntax.
+ */
+function ctools_form_include_file(&$form_state, $filename) {
+ if (!isset($form_state['build_info']['args'])) {
+ $form_state['build_info']['args'] = array();
+ }
+
+ // Now add this to the build info files so that AJAX requests will know to load it.
+ $form_state['build_info']['files']["$filename"] = $filename;
+ require_once DRUPAL_ROOT . '/' . $filename;
+}
+
+/**
* Provide the proper path to an image as necessary.
*
* This helper function is used by ctools but can also be used in other
diff --git a/includes/wizard.inc b/includes/wizard.inc
index 50cd79c..b823920 100644
--- a/includes/wizard.inc
+++ b/includes/wizard.inc
@@ -46,6 +46,10 @@
* whatever information the form(s) involved left for it.
*/
function ctools_wizard_multistep_form($form_info, $step, &$form_state) {
+ // Make sure 'wizard' always exists for the form when dealing
+ // with form caching.
+ ctools_form_include($form_state, 'wizard');
+
// allow order array to be optional
if (empty($form_info['order'])) {
foreach ($form_info['forms'] as $step_id => $params) {
@@ -104,11 +108,11 @@ function ctools_wizard_multistep_form($form_info, $step, &$form_state) {
if (!empty($info['include'])) {
if (is_array($info['include'])) {
foreach ($info['include'] as $file) {
- require_once DRUPAL_ROOT . '/' . $file;
+ ctools_form_include_file($form_state, $file);
}
}
else {
- require_once DRUPAL_ROOT . '/' . $info['include'];
+ ctools_form_include_file($form_state, $info['include']);
}
}