summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--includes/admin.inc43
-rw-r--r--modules/field/views_handler_field_field.inc10
-rw-r--r--plugins/views_plugin_display.inc8
3 files changed, 55 insertions, 6 deletions
diff --git a/includes/admin.inc b/includes/admin.inc
index 601ae3e..18f3437 100644
--- a/includes/admin.inc
+++ b/includes/admin.inc
@@ -4193,6 +4193,44 @@ function views_ui_config_item_form_validate($form, &$form_state) {
}
/**
+ * A submit handler that is used for storing temporary items when using
+ * multi-step changes, such as ajax requests.
+ */
+function views_ui_config_item_form_submit_temporary($form, &$form_state) {
+ // Run it through the handler's submit function.
+ $form_state['handler']->options_submit($form['options'], $form_state);
+ $item = $form_state['handler']->options;
+ $types = views_object_types();
+
+ $type = $form_state['type'];
+ if (!empty($types[$type]['type'])) {
+ $type = $types[$type]['type'];
+ }
+
+ // Create a new handler and unpack the options from the form onto it. We
+ // can use that for storage.
+ $handler = views_get_handler($item['table'], $item['field'], $type);
+ $handler->init($form_state['view'], $item);
+
+
+ // Add the incoming options to existing options because items using
+ // the extra form may not have everything in the form here.
+ $options = $form_state['values']['options'] + $form_state['handler']->options;
+
+ // This unpacks only options that are in the definition, ensuring random
+ // extra stuff on the form is not sent through.
+ $handler->unpack_options($handler->options, $options, NULL, FALSE);
+
+ // Store the item back on the view
+ $form_state['view']->temporary_options[$type][$form_state['id']] = $handler->options;
+
+ $form_state['rerender'] = TRUE;
+ $form_state['rebuild'] = TRUE;
+ // Write to cache
+ views_ui_cache_set($form_state['view']);
+}
+
+/**
* Submit handler for configing new item(s) to a view.
*/
function views_ui_config_item_form_submit($form, &$form_state) {
@@ -4223,6 +4261,11 @@ function views_ui_config_item_form_submit($form, &$form_state) {
// Store the item back on the view
$form_state['view']->set_item($form_state['display_id'], $form_state['type'], $form_state['id'], $handler->options);
+ // Ensure any temporary options are removed.
+ if (isset($form_state['view']->temporary_options[$type][$form_state['id']])) {
+ unset($form_state['view']->temporary_options[$type][$form_state['id']]);
+ }
+
// Write to cache
views_ui_cache_set($form_state['view']);
}
diff --git a/modules/field/views_handler_field_field.inc b/modules/field/views_handler_field_field.inc
index 3a223f4..f63c3fd 100644
--- a/modules/field/views_handler_field_field.inc
+++ b/modules/field/views_handler_field_field.inc
@@ -298,6 +298,8 @@ class views_handler_field_field extends views_handler_field {
'#ajax' => array(
'path' => views_ui_build_form_url($form_state),
),
+ '#submit' => array('views_ui_config_item_form_submit_temporary'),
+ '#executes_submit_callback' => TRUE,
);
$form['field_api_classes'] = array(
@@ -313,12 +315,8 @@ class views_handler_field_field extends views_handler_field {
}
// Get the currently selected formatter.
- if (isset($form_state['values']['options']['type'])) {
- $format = $form_state['values']['options']['type'];
- }
- else {
- $format = $this->options['type'];
- }
+ $format = $this->options['type'];
+
$formatter = field_info_formatter_types($format);
$settings = $this->options['settings'] + field_info_formatter_settings($format);
diff --git a/plugins/views_plugin_display.inc b/plugins/views_plugin_display.inc
index 8985a56..210dbcb 100644
--- a/plugins/views_plugin_display.inc
+++ b/plugins/views_plugin_display.inc
@@ -741,7 +741,15 @@ class views_plugin_display extends views_plugin {
$this->handlers[$type] = array();
$types = views_object_types();
$plural = $types[$type]['plural'];
+
foreach ($this->get_option($plural) as $id => $info) {
+ // If this is during form submission and there are temporary options
+ // which can only appear if the view is in the edit cache, use those
+ // options instead. This is used for AJAX multi-step stuff.
+ if (isset($_POST['form_id']) && isset($this->view->temporary_options[$type][$id])) {
+ $info = $this->view->temporary_options[$type][$id];
+ }
+
if ($info['id'] != $id) {
$info['id'] = $id;
}