If I have a date combo field that I haven't enabled the checkbox for Chosen in the widget settings, then any select fields like day and hour still get converted to Chosen fields because they meet the default criteria in the site-wide/global settings. We have two options to resolve this:

Current behavior:

switch ($context['instance']['widget']['settings']['apply_chosen']) {
  case 0:
    // Do nothing. Site-wide criteria may still match select elements in this field widget.
    break
  case 1:
    // Apply chosen to select elements in this widget.
    break;
}

Solution 1

Chosen is either enabled or disabled for the widget. There is no in-between behavior. This would change existing widgets that have the '0' value that normally would match the site-wide conditions that get Chosen applied, to not having Chosen applied.

switch ($context['instance']['widget']['settings']['apply_chosen']) {
  case 0:
    // Force chosen to not be enabled for this widget.
    break
  case 1:
    // Apply chosen to select elements in this widget.
    break;
}

I do like that this is more explicit. It's either on or off.

Solution 2

Add a new 'no preference' option.

switch ($context['instance']['widget']['settings']['apply_chosen']) {
  case '':
    // Do nothing but site-wide criteria may still match select elements in this field widget.
    break
  case 0:
    // Force chosen to not be enabled for this widget.
    break;
  case 1:
    // Apply chosen to select elements in this widget.
    break;
}

Solution 3

Use the options in Solution 2, but use different defaults based on the field type. Default for options_select is '' (no preference), default for date_combo is 0 (do not apply).

Need to think about what is the best option. I'm leaning towards Solution 3 because there is a nice value to having Chosen apply to select widgets when possible by default.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

Dave Reid’s picture

Issue summary: View changes
Dave Reid’s picture

Issue summary: View changes
Dave Reid’s picture

Status: Active » Needs review
FileSize
3.15 KB

Patch that implements solution 3.

Dave Reid’s picture

Status: Needs review » Fixed

Tested and committed #3 to 7.x-2.x.: http://drupalcode.org/project/chosen.git/commit/7b187f8

Status: Fixed » Closed (fixed)

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