? .svn ? betterselect-behaviors-376710-1.patch ? betterselect-save_lineage-380898-1.patch ? betterselect-save_lineage-380898-2.patch ? betterselect-save_lineage-380898-3.patch ? betterselect-unique_ids-376968-1.patch Index: betterselect.js =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/betterselect/betterselect.js,v retrieving revision 1.2 diff -u -p -r1.2 betterselect.js --- betterselect.js 6 Sep 2008 03:20:19 -0000 1.2 +++ betterselect.js 23 Feb 2009 12:52:32 -0000 @@ -1,5 +1,8 @@ -$(document).ready(function() { +// $Id$ + +Drupal.behaviors.initBetterSelect = function(context) { $('.better-select .form-checkboxes input[@type="checkbox"]').click(function(){ this.checked ? $(this).parent().parent().addClass('hilight') : $(this).parent().parent().removeClass('hilight'); }).filter(":checked").parent().parent().addClass('hilight'); -}); \ No newline at end of file +} + Index: betterselect.module =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/betterselect/betterselect.module,v retrieving revision 1.4.2.1 diff -u -p -r1.4.2.1 betterselect.module --- betterselect.module 11 Sep 2008 01:02:30 -0000 1.4.2.1 +++ betterselect.module 23 Feb 2009 12:52:33 -0000 @@ -40,6 +40,12 @@ function betterselect_admin_settings() { '#default_value' => variable_get('betterselect_node_form_only', FALSE), ); + $form['betterselect_save_lineage'] = array( + '#type' => 'checkbox', + '#title' => t('If a user selects a child term, automatically save the parent term too.'), + '#default_value' => variable_get('betterselect_save_lineage', FALSE), + ); + return system_settings_form($form); } @@ -80,7 +86,7 @@ function betterselect_process($element, if (isset($element['#default_value']) && is_array($element['#default_value']) && count($element['#default_value'])) { // Fix the value arrays; checkboxes are the exact inverse of multiselect, // apparently for vindictive fun. - + // First make sure there's at least 1 non-blank array element $temp = $element['#default_value']; $temp = array_shift($element['#default_value']); @@ -88,7 +94,7 @@ function betterselect_process($element, $element['#default_value'] = array_flip($element['#default_value']); $element['#value'] = array_flip($element['#value']); } - + } @@ -120,7 +126,8 @@ function betterselect_process($element, $prefix = isset($element['#prefix']) ? $element['#prefix'] : ''; $suffix = isset($element['#suffix']) ? $element['#suffix'] : ''; $fixheight = count($element['#options']) > $size ? ' betterfixed' : ''; - $element['#prefix'] = '
' . $prefix; + $id = 'better-select-' . $element['#id']; + $element['#prefix'] = '
' . $prefix; $element['#suffix'] = $suffix . '
'; } return $element; @@ -163,9 +170,17 @@ function betterselect_taxonomy_from_chec foreach ($form_state['values']['taxonomy'][$index] as $tid => $selected) { if ($selected) { $options[$tid] = $tid; + + // save lineage. automatically select all parents. + if (variable_get('betterselect_save_lineage', FALSE)) { + $parents = taxonomy_get_parents($tid); + foreach ($parents as $key => $val) { + $options[$key] = $key; + } + } } } $form_state['values']['taxonomy'][$index] = $options; } } -} \ No newline at end of file +}