Skip to content
This repository has been archived by the owner on Mar 4, 2019. It is now read-only.

Commit

Permalink
Unset dc and dch before form submit (fix #4)
Browse files Browse the repository at this point in the history
  • Loading branch information
dashohoxha committed Aug 30, 2015
1 parent 71235a2 commit 5afab68
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
8 changes: 7 additions & 1 deletion ajax_chain_select.module
Original file line number Diff line number Diff line change
Expand Up @@ -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'])),
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 0 additions & 2 deletions ajax_chain_select_example/ajax_chain_select_example.module
Original file line number Diff line number Diff line change
Expand Up @@ -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: <pre>@values</pre>', array('@values' => $submitted_values)));
}
Expand Down

0 comments on commit 5afab68

Please sign in to comment.