From 23dbb2c99d43e8329e0db6d9b419e654b0361919 Mon Sep 17 00:00:00 2001 From: Jesse Hofmann-Smith Date: Thu, 16 Oct 2014 17:36:45 -0700 Subject: [PATCH] make diff View changes button also not reset form --- hierarchical_select.module | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/hierarchical_select.module b/hierarchical_select.module index 02b2797..2b5f57b 100644 --- a/hierarchical_select.module +++ b/hierarchical_select.module @@ -807,8 +807,19 @@ function form_hierarchical_select_process($element, &$form_state, $complete_form // is NOT erased, the corresponding value in $form_state['input'] will be // used instead of the default value that was set. This would result in // undesired behavior. - drupal_array_set_nested_value($form_state['input'], $element['#array_parents'], array()); - + // This, however, must not be called on node preview, becuase in that case + // the node will be rebuilt and we need the values inside $form_state['input'] + // to recreate the edited form properly. + // @TODO: If the form is rebuilt by some other action than a node preview, we + // might lose data again, we should see if there's any way to prevent this from + // happening by setting this value after the form has been flagged to be rebuilt, + // but as far as I checked, there's not. + // Another option might be to rework the need of this function to prevent + // the undesired behaviors of not having it with some other logic that would + // work as well if the form is rebuilt. + if (!isset($form_state['triggering_element']) || ($form_state['triggering_element']['#value'] != t('Preview') && $form_state['triggering_element']['#value'] != t('View changes'))) { + drupal_array_set_nested_value($form_state['input'], $element['#array_parents'], array()); + } // Send the collected developer mode logs (by using #attached JS). $element = _hs_process_developer_mode_send_log_js($element, $hsid); -- 1.9.3 (Apple Git-50)