Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Basically #2213231: Make it possible to force-disable Chosen for a field widget but adapted for Webform select components.
Comment | File | Size | Author |
---|---|---|---|
#13 | interdiff-2214247-8-13.txt | 445 bytes | drclaw |
#13 | 2214247-chosen-webform-toggle-13.patch | 6.67 KB | drclaw |
| |||
#8 | interdiff-2214247-7-8.txt | 572 bytes | scottrigby |
#8 | 2214247-chosen-webform-toggle-8.patch | 7.17 KB | scottrigby |
Comments
Comment #1
Dave ReidComment #2
johnennew CreditAttribution: johnennew commentedCan date fields be included in this as well? They also get rendered as 3 select drop downs on webform.
Comment #3
johnennew CreditAttribution: johnennew commentedPlease find updated patch with chosen toggle for date fields applied as well.
Comment #4
joelpittetThis works fairly good but if you leave no preference, it seems to pickup it's value from previous select fields. It should be picking up from the global setting right? That is how the field UI stuff works with no preference.
May have something to do with that note in the comments about Webforms turning off prerender?
Comment #5
ericshell CreditAttribution: ericshell commentedFrom everything else I have found, this seems to be the issue. @Dave Reid mentioned he created an issue for the Webform module but I have not been able to find it to aid in resolving this issue.
I have also created this post which has not gotten much activity:. http://drupal.stackexchange.com/questions/129489/webform-capability-issu...
After applying the patch above, the select fields in the webform were still not wrapped by the chosen module. Even after configuring the module to wrap all select options and clearing the cache again, the chosen module was still not being applied.
Comment #6
Dave ReidYeah, we should just probably remove this. And confirm which webform element types would need to have #pre_render added all the time (we know select does, not sure about the rest).
Comment #7
scottrigbyHey guys,
So this new patch doesn't address #4 or #6 yet, but does support webform conditionals (otherwise Chosen keeps it's pseudo element disabled).
The JS code is mostly based on webform.js (only the conditionals section), which is namespaced for Chosen, and needed to trigger a Chosen library redraw/update method (documented here https://harvesthq.github.io/chosen/#change-update-events).
Also attaching an interdiff with #3.
Comment #8
scottrigbyOK this patch is ready for review:
Including interdiff against #7.
Comment #9
joelpittet@scottrigby gave this a try with date popup select and it didn't seem to update chosen.
Comment #10
joelpittetTo resolve date select fields not updating I just dropped this in a behaviour.
Comment #11
Martijn de WitUsing patch (#8) because chosen was not applied to my webforms. It now works great!
I only had to manually apply the code to my files. The patch file didn't work in source-tree and gave some error's about matching files...
Comments in Issue https://www.drupal.org/node/2122061 weren't helping a lot, but this patch did the trick :)
Comment #12
ahillio CreditAttribution: ahillio commentedPatch in #8 applied successfully to 2.0-beta4, got chosen on my webform select options now. Thanks @scottrigby!
Comment #13
drclaw CreditAttribution: drclaw commentedI believe this is causing an unrecognized expression error because the $form selector was generated using the jquery
.closest()
function. That produces an invalid jquery selector like this:.closest(.webform-component).closest(form) .webform-component--my-component select
. Additionally, I believe the$element.selector
property has been removed in jQuery > 1.8.x. Might I suggest passing the$target
element in as the selector context instead? This has the added bonus of likely being more performant since jQuery won't have to search the whole DOM for the select element.Re-roll of Patch & interdiff attached!
Comment #15
nubeli CreditAttribution: nubeli commentedI tried the patch in #13. It applied well enough to chosen 7.x-2.0-beta5. When I go to the components page of a webform with an existing select element I get an error:
If I delete the select element and re-add it then the patch works okay. So seems that it just needs to account for existing select elements in webform not yet having any preference?
Comment #16
deranga CreditAttribution: deranga commentedJust wondering, for the date element piece, can we not just add ".chosen-disable select" as follows in chosen.js:
And then under the webform components we don't want chosen applied to add the chosen-disable class to the wrapper?
Comment #17
delacosta456 CreditAttribution: delacosta456 commentedHi
in this logic , if not already exist and if it make sense is it possible to have chosen contextualy activated :
- by path
-by node type
-by entity
thanks
Comment #18
joelpittetHeads up my suggestion in #10 still works.
Full code for the copy pasters out there.
Comment #19
tzt20 CreditAttribution: tzt20 as a volunteer commentedI ran into this issue just as you posted your solution @joelpittet. #10/#18 works like a charm. Thanks.
Comment #20
Elvin - Albania Drupal Developer CreditAttribution: Elvin - Albania Drupal Developer commentedThank you @joelpittet #18 solved it like a charm!!!