I have a global filter block filtering on a taxonomy reference field, with the 'Multi choice check boxes' widget, and 'Invoke widget immediately upon select' enabled.

The filter block shows up as expected, but the 'All' option doesn't seem to work. I expected 'All' to clear the current selection, but that doesn't happen. Selecting 'All' does trigger a POST request, but the only effect is that 'All' comes back unselected and nothing changed.

Is this a bug, or did I do something wrong in the configuration?

Comments

RdeBoer’s picture

Category: bug » feature
Status: Active » Needs work

Hi Marc,
It's kind of a bug.
'All', 'Invoke immediately' and 'Mutli choice check boxes' don't go together very well. Not out-of-the-box anyway.
I believe there's a warning on the block configuration page that discourages the use of 'All' in this combination.

This may have to be fixed with additional javascript.

Any takers?

Rik

marcvangend’s picture

Thanks for the reply, Rik. I did see the notice about 'Invoke immediately', but turning that off didn't change anything. I did not see a warning about the combination of 'All' and 'Multi choice check boxes'.

Anyway, I'll see if I can use my (limited) js/jQuery knowledge to find out how to fix this.

jlcerrada’s picture

Issue summary: View changes

I had the same problem with the 'multi choice check' and I solved it with the following js code.

var global_filter   = $('#global-filter-1');
var all_checkbox    = global_filter.find('#edit-view-group-terms-'); // all checkbox input
var checkboxes;

all_checkbox.change(function () {
  if($(this).prop('checked')) {
    checkboxes = global_filter.find('#edit-view-group-terms .form-item input'); // all checkboxes
    checkboxes.prop('checked', false);
    checkboxes.change();
  }
});
ybabel’s picture

My solution in templates/block--global-filter.tpl.php :

<?php if ($content): ?>
    <?php print $content; ?>
<?php endif;?>

<script type='text/javascript'>
(function ($) {
var global_filter   = $('#global-filter-1');
var all_checkbox    = global_filter.find('#edit-field-domaine-'); // all checkbox input
var checkboxes;
all_checkbox.change(function () {
  if($(this).is(':checked')) {
    checkboxes = global_filter.find('#edit-field-domaine .form-item input:not(:checked)'); // all checkboxes
    checkboxes.attr('checked', true);
  }
});

}(jQuery));
</script>

works with standard drupal jQuery