Index: taxonomy_super_select.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/taxonomy_super_select/taxonomy_super_select.module,v retrieving revision 1.10.2.1 diff -u -p -r1.10.2.1 taxonomy_super_select.module --- taxonomy_super_select.module 21 Jan 2009 22:44:21 -0000 1.10.2.1 +++ taxonomy_super_select.module 29 Jul 2009 16:12:02 -0000 @@ -86,6 +86,7 @@ function taxonomy_super_select_form_alte unset($form['taxonomy'][$vid]); } } + $form['#validate'][] = 'taxonomy_super_select_node_form_validate'; } // Go through each enabled vocab and create taxonomy super select @@ -307,6 +308,29 @@ function taxonomy_super_select_nodeapi(& } } +/** + * Validate node_form submissions. + * Remove taxonomy terms with a value of zero + */ +function taxonomy_super_select_node_form_validate($form, &$form_state) { + $taxonomy = $form_state['values']['taxonomy']; + if (is_array($taxonomy)) { + $form_state['values']['taxonomy'] = _tss_filter_recursive($taxonomy); + } +} + +/** + * Recursively apply array_filter() to an array. + */ +function _tss_filter_recursive($input) { + foreach ($input as &$value) { + if (is_array($value)) { + $value = _tss_filter_recursive($value); + } + } + return array_filter($input); +} + function taxonomy_super_select_submit(&$form, $form_state) { $vid = $form['vid']['#value']; if (count($form['settings']['tss']['taxonomy_super_select_vid_'. $vid])) {