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.
When I choose the Autocomplete (Tags style) widget, the chosen/chosen_ajax widget used doesn't allow for multiple tags/values to be entered, even though the field allows for unlimited values. Disabling chosen_ajax, or switching to Autocomplete allows me to once again enter multiple values.
Is this a bug, or some sort of technical limitation?
Comment | File | Size | Author |
---|---|---|---|
#22 | 2217629-22-chosen_ajax-autocomplete-tagging.patch | 8.58 KB | monstrfolk |
Comments
Comment #1
karlkablisk2 CreditAttribution: karlkablisk2 commentedNo answer yet? :(
Comment #2
Mike Draconid CreditAttribution: Mike Draconid commentedi have modified it to support multiple by adding
'#multiple' => TRUE,
in form API
Comment #3
Mike Draconid CreditAttribution: Mike Draconid commentedupdated, for a bug fix
Comment #4
estoyausente#3 Code works correctly, and the field is rendered correctly too. Thanks.
Comment #5
dwebpoint CreditAttribution: dwebpoint as a volunteer commented#3 works for element which was created with Form API only. It doesn't resolve the issue.
Comment #6
botrisThis code, instead of the snippet in #3, enables the multi value widget for me:
But it does not yet save the value.
Comment #7
botrisThe I'm using a.t.m. is to process the results in a validate function next to using #6:
Comment #8
EugeneChechel CreditAttribution: EugeneChechel commented@botris where did you put your code? Could you please share an example?
Comment #9
botris@EugeneChechel so I used this code in a custom form, and it works for submissions, but when editing an existing form I got in real trouble :)
So after a while of debugging I decided it was too much time to work around, so I don't use Chosen ajax anymore, the combination I use now that works really well is:
https://www.drupal.org/project/autocomplete_deluxe
with https://www.drupal.org/project/acdx_references
patched with https://www.drupal.org/node/1295034#comment-10329839
If you do decide to stick with Chosen ajax you would put the part from #6 in your form code or when altering an existing form in a hook_form_alter().
The code from #7 would go in a form validation function.
Hope that helps.
Comment #10
chertzogHere is a patch that makes this work for me.
Comment #11
monstrfolk CreditAttribution: monstrfolk commentedPatch was created incorrectly. I fixed the patch and remove unneeded code.
Comment #12
monstrfolk CreditAttribution: monstrfolk commentedComment #13
monstrfolk CreditAttribution: monstrfolk commentedThis issue is fixed. I would really appreciate it if anyone could test this. Perhaps @Mike Draconid, @botris, @chertzog, or anyone else that gets this message could test.
Comment #14
monstrfolk CreditAttribution: monstrfolk commentedSmall change to patch that removes the size attribute from the select html tag. Adds 'form-select' class to the html select element to conform with Drupal.
Comment #15
monstrfolk CreditAttribution: monstrfolk commentedOne more fix when using chosen ajax single item.
Notice: Undefined index: multiple in chosen_ajax_theme_textfield() (line 219 of /sites/all/modules/chosen_ajax/chosen_ajax.module).
Comment #16
monstrfolk CreditAttribution: monstrfolk commentedUpdated patch. Solves many issues.
Comment #17
monstrfolk CreditAttribution: monstrfolk commentedA fix for single chosen when creating new content.
Comment #18
monstrfolk CreditAttribution: monstrfolk commentedMore updates and changes.
Comment #19
monstrfolk CreditAttribution: monstrfolk commentedRemoved watchdog output.
Comment #20
monstrfolk CreditAttribution: monstrfolk commentedComment #21
monstrfolk CreditAttribution: monstrfolk commentedNew patch. Everything should be good with this one.
Tested with....
autocomplete, cardinality 1, non fixed display
autocomplete, cardinality unlimited, non fixed display
autocomplete, cardinality 1, fixed display
autocomplete, cardinality unlimited, fixed display
autocomplete, cardinality 1, non fixed display, required
autocomplete, cardinality unlimited, non fixed display, required
autocomplete, cardinality 1, fixed display, required
autocomplete, cardinality unlimited, fixed display, required
autocomplete tags, cardinality 1, non fixed display
autocomplete tags, cardinality unlimited, non fixed display
autocomplete tags, cardinality 1, fixed display
autocomplete tags, cardinality unlimited, fixed display
autocomplete tags, cardinality 1, non fixed display, required
autocomplete tags, cardinality unlimited, non fixed display, required
autocomplete tags, cardinality 1, fixed display, required
autocomplete tags, cardinality unlimited, fixed display, required
Comment #22
monstrfolk CreditAttribution: monstrfolk commentedComment #23
monstrfolk CreditAttribution: monstrfolk commentedAny updates?
Comment #25
dwebpoint CreditAttribution: dwebpoint as a volunteer commented@monstrfolk thanks a lot for the patch.
Comment #26
monstrfolk CreditAttribution: monstrfolk commented