diff --git a/ajax_chain_select.module b/ajax_chain_select.module index d9188a1..cde6824 100644 --- a/ajax_chain_select.module +++ b/ajax_chain_select.module @@ -62,6 +62,7 @@ function ajax_chain_select_element_process($element, &$form_state, $form) { ); $chain_select_element[$element_name] = array( + '#element_name' => $element_name, '#type' => 'fieldset', '#tree' => TRUE, '#id' => !empty($element['#id']) ? $element['#id'] : drupal_html_id('edit-' . implode('-', $element['#parents'])), @@ -153,9 +154,14 @@ function ajax_chain_select_element_process($element, &$form_state, $form) { * Custom function for ac_select element validate. */ function ajax_chain_select_custom_validate(&$element, &$form_state, $form) { - $values = $form_state['values']; + // Clean up fields 'dc' and 'dch'. + $element_name = $element['#element_name']; + unset($form_state['values'][$element_name]['dc']); + unset($form_state['values'][$element_name]['dch']); + $data_callback = $element['#data_callback']; $config = $element['#config']; + $values = $form_state['values']; $index = 0; $levels = array_keys($config); diff --git a/ajax_chain_select_example/ajax_chain_select_example.module b/ajax_chain_select_example/ajax_chain_select_example.module index b2ce3ff..61b96a7 100644 --- a/ajax_chain_select_example/ajax_chain_select_example.module +++ b/ajax_chain_select_example/ajax_chain_select_example.module @@ -70,8 +70,6 @@ function ajax_chain_select_example_sample_form($form, &$form_state) { */ function ajax_chain_select_example_sample_form_submit($form, &$form_state) { $values = $form_state['values']['region']; - unset($values['dc']); - unset($values['dch']); $submitted_values = print_r($values, 1); drupal_set_message(t('The form has been successfully submitted with values:
@values', array('@values' => $submitted_values))); }