Early Bird Registration for DrupalCon Portland 2024 is open! Register by 23:59 UTC on 18 March 2024, to get $100 off your ticket.
I'm not sure what's happening here. I have chosen working great on another site, but I've recently taken over a new site that has all kinds of fun quirks. One being, on multi-select chosen fields, none is an option. So I can choose Option 1, Option 2 and none. All at once.
Can anyone give me a heads up of where I might be able to fix that? It would be greatly appreciated. I'm certain I'm not finding a bug, but I can't find anyone with a similar issue when I search. Maybe it's something simple I'm not realizing.
Comment | File | Size | Author |
---|---|---|---|
#21 | 2117827-21.patch | 5.77 KB | jhedstrom |
| |||
#19 | 2117827-19-TEST-ONLY.patch | 2.24 KB | jhedstrom |
Comments
Comment #1
zilla CreditAttribution: zilla commentedis it possible that this is specific to the field for the taxonomy (or select list) - where the field is not required and so presents a 'none' option?
Comment #2
stupiddingo CreditAttribution: stupiddingo commentedYou can unset the none option in your own module:
I image one could implement this inside of chosen as well removing _none from all chosen widgets.
Comment #3
stupiddingo CreditAttribution: stupiddingo commentedHere's an attempt at adding this functionality to chosen. Works in the tests I have available. Needs review.
Comment #4
Elin Yordanov CreditAttribution: Elin Yordanov commentedAttached is a new patch for the current 7.x-2.x-dev version. Please review.
Comment #5
caminadaf CreditAttribution: caminadaf commentedWorked perfectly. +1 RTBC
Comment #7
maximpodorov CreditAttribution: maximpodorov commentedI just renamed the patch file to become more standardized.
Comment #8
carolpettirossi CreditAttribution: carolpettirossi at CI&T commented#7 worked for me. +1 RTBC
Comment #10
nagy.balint CreditAttribution: nagy.balint commentedThanks, seems to work fine, Committed.
Comment #11
mr.york CreditAttribution: mr.york at Agence Inovae commentedDrupal 8 version.
Comment #12
nagy.balint CreditAttribution: nagy.balint commentedAbout the Drupal 8 port: So far this patch and the related cardinality setup in chosen code is not working, cause entity type is not available in the pre render function, so we cannot load the field settings (as in drupal 8 field with same name can be in different entities).
Comment #13
mr.york CreditAttribution: mr.york at Agence Inovae commentedI corrected the field config loading, but it needs the #2678824: The widget form element does not contain the bundle and the entity type (core patch) to make it work actually.
Comment #14
nagy.balint CreditAttribution: nagy.balint commentedCommitted the patch.
Since it has isset checks, it wont cause any problem if the core patch is not in yet, and the current code that it replaces also does not work.
But this way, once the core patch is in, it will just start to work, or if we find another way then we can just make another patch that continues from here.
Putting it on postponed til we have news on the core patch.
Comment #16
esmith818 CreditAttribution: esmith818 commentedIs it possible that this patch (D7) is indirectly responsible for a possible bug on iOS devices when using a multi-select field that has no value by default and is not required?
On other platforms, an empty value (1-initial-value.png) remains intact unless an option(s) is manually selected in the list. But on iOS devices, once the user clicks the field, the first selection is automatically chosen (2-click-field.png) and the user must choose "Done" and then re-enter the list to manually uncheck the first option (4-reenter-to-fix.png). If they also manually choose another value (3-click-value.png), by default TWO values are selected.
I had thought this was due to iOS' unique UI of scrolling through options, but I see that the same behavior is NOT present on the sample multi-select at http://harvesthq.github.io/chosen/
If this issue is addressed elsewhere, please direct me to a link. I could not find a solution via several searches.
Comment #17
jhedstromOver in #2678824: The widget form element does not contain the bundle and the entity type, it appears that there is actually access to everything a contrib module needs here. This patch adds the elements via the
hook_field_widget_form_alter()
, and adds a test. If this is good, then that core patch is no longer technically needed.Comment #19
jhedstromThere was a typo in the new test so it wasn't run, and the test was also using the wrong assertion method. There were also tests explicitly checking for the _none functionality on multivalue widgets, so this patch removes those.
Comment #21
jhedstromThe patch in #19 has issues with base field definitions. On base fields, the
bundle
property is null. The updated patch only uses the#bundle
property to fetch the cardinality, and unsets the_none
option for all multiselect fields.Comment #22
mr.york CreditAttribution: mr.york at Agence Inovae commentedWorks for me. Good patch.
Comment #24
nagy.balint CreditAttribution: nagy.balint commentedThanks.
Comment #26
nvahalik CreditAttribution: nvahalik at Code and Salt commentedNote that the 2.x branch which applies this fix will break if you are already removing these values within your code. The module doesn't test to see if that option even exists and it will throw a fatal error if it tries to remove it and it is not there.