Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Hydra’s picture

Status: Active » Postponed

Yeah true! This is a nice feature but I will postpone it till the new alpha-3 release has been released. There are already big plans for a 3.x branch in #2076707: Introduce plugin system for chosen module and I will add your request to the list at #2076813: Move library options (configuration) to library plugin so we won't forget it.

Thanks a lot for your input!

rp7’s picture

All right!

In the mean while, I already made a patch providing this functionality for the 2.x branch. Might still be useful.

Hydra’s picture

Nice! So everyone searching for this feature, can use it! I did a quick review on your code. Perhaps we will add later to 2.x, but not without #2064325: Revise configuration page, because when we once added a new option, the next will come and so on...
But very nice of you to share a patch, very appreciated!

  1. +++ b/chosen.admin.inc
    @@ -73,6 +73,13 @@ function chosen_admin_settings($form, &$form_state) {
    +  ¶
    

    Whitespace

  2. +++ b/chosen.admin.inc
    @@ -73,6 +73,13 @@ function chosen_admin_settings($form, &$form_state) {
    +    '#default_value' => variable_get('chosen_allow_single_deselect', FALSE),
    

    The variable needs to be removed from the system when uninstalling the module, have a quick look at chosen.install how it works!

rp7’s picture

That's odd - can't see the whitespace. What tool/command are you using to track it down? (I'm not very up to date on Git/creating patches)

Missed the chosen.install part - my bad. New patch attached.

Hydra’s picture

+++ b/chosen.admin.inc
@@ -73,6 +73,13 @@ function chosen_admin_settings($form, &$form_state) {
+  ¶

Still there ;)

You can configure your editor to show whitespaces or even terminate them (what would be the "less work" way).
However, I recommend you to install dreditor plugin to your browser, have a look at http://dreditor.org, this is a really great tool to review patches on drupal.org. Using the preview function, you can have a look with it on your patch, before posting it :)

marcvangend’s picture

Issue summary: View changes

This would be a great feature, I've been scratching my head for a while figuring out why I could not deselect...

This issue was postponed on the alpha-3 release, but since we're on alpha-4 now, I guess it's time to re-open.

That said, I would like to suggest a slightly different aproach. The allow_single_deselect option is closely related to the question if a select box is required or not. As the Chosen documentation says:

When a single select box isn't a required field, you can set allow_single_deselect: true and Chosen will add a UI element for option deselection.

So, instead of making this a global option, I think it would be much nicer if we can apply the option automatically, depending on the #required property of the form element. After all, there is no point in clearing the value on a required field. Likewise, it doesn't make sense to disallow users to clear a non-required field.

Elijah Lynn’s picture

Status: Postponed » Needs work

Yeah, this has been postponed too long, reopening.

scottAtRoot802’s picture

Has there been any progress with this. I was able to apply the patch, but it would be nice if this was integrated into the next version.

nagy.balint’s picture

I guess comment #1 is not going to happen any time soon.

So first we need to reroll the patch, and then I suppose since its a trivial addition we can commit it.

aludescher’s picture

Patch re-rolled against 7.x-2.x branch.

aludescher’s picture

Status: Needs work » Needs review

The last submitted patch, 2: allow_deselect_on_single_selects-2083147-1.patch, failed testing.

The last submitted patch, 4: chosen-allow_deselect_on_single_selects-2083147-4.patch, failed testing.

Status: Needs review » Needs work

The last submitted patch, 10: chosen-allow_deselect_on_single_selects-2083147-10.patch, failed testing.

aludescher’s picture

  • nagy.balint committed 0e23416 on 7.x-2.x authored by RaF7
    Issue #2083147 by RaF7, silversk8r, Hydra: Allow deselect on single...
nagy.balint’s picture

Status: Needs work » Fixed

Thanks, Committed.

About #6, the issue is that simply setting a field not required will not trigger this functionality, cause the first option will be - None - instead of empty. So in order to make this work we also need a form alter in fact, or a custom select list constructed from code.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

nithinkolekar’s picture

+1 for #6
If any one is using chosen in views exposed filter over Autocomplete deluxe issue #1079826: Autocomplete Deluxe Widget as Views Filter? you might have known first element in the list is -Any- with a value All, which makes the views to load all results.
So with addition to empty string All text should be excluded.