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.
I have a node edit form where I allow up to 3 terms to be selected, but with the chosen module it will keep letting me choose terms and not until I save it does it give any error. I would think that after 3 terms are selected it would prevent me from selecting more.
Comment | File | Size | Author |
---|---|---|---|
#2 | chosen.miscellaneous.2035723-2.patch | 2.14 KB | Hydra |
Comments
Comment #1
Hydra CreditAttribution: Hydra commentedAgree, this would be the suggested behavior.
Using the max_selected_options option, this should be possible. It will be kinda tricky to get this information out of the select field.
Comment #2
Hydra CreditAttribution: Hydra commentedOkay, we came up with a solution to transfer field specific settings to the plugin in #2023007: Separate minimum number of elements for single and multiselect., which can simply be adapted for this case. The following patch should transfer the field maximum values setting to chosens "max_selected_options" like I suggested in #1. Therefor chosen should stop letting you selecting more values in multivalue fields.
Comment #3
Harlor CreditAttribution: Harlor commentedwell this seems to work well. Hopefully it will be merged into the next stable release.
Comment #4
Hydra CreditAttribution: Hydra commentedUPS, okay I removed the dsm I forgot. Thanks for your review. Pushed to 7.x-2.x
http://drupalcode.org/project/chosen.git/commit/4b744f7
Comment #5
xbrianx CreditAttribution: xbrianx commentedI just updated to the new dev version and am still able to load more terms than allowed. When saving the content I received this error:
Notice: Undefined index: #multiple in chosen_pre_render_select() (line 178 of /home/site/public_html/testing/sites/all/modules/chosen/chosen.module).
Comment #6
Hydra CreditAttribution: Hydra commentedWell this looks like you did not clear your cache ;)
Comment #7
xbrianx CreditAttribution: xbrianx commentedI wish that was the case :( . I cleared the cache and ran updates twice. I didn't see an update to the library though maybe I need to do that?
Comment #8
Hydra CreditAttribution: Hydra commentedCan you check if #2079255: Chosen does not work on Multi-Select fields where Unlimited values are allowed. fixed the issue for you?
Comment #9
xbrianx CreditAttribution: xbrianx commentedGreat, I just installed the latest dev version and all is good now.
Comment #10
Hydra CreditAttribution: Hydra commentedOkay nice, so this is finaly fixed!
Comment #12
goldlilys CreditAttribution: goldlilys commentedFor some reason, the maximum option is gone from the chosen settings page and only see the minimum. Was this not added to the new version?
Comment #13
goldlilys CreditAttribution: goldlilys commentedComment #14
gauravkhambhala CreditAttribution: gauravkhambhala at KNOWARTH commentedYes, Correct. The latest beta release does not show maximum allowed option. Probably above patch needs to be revised and applied to latest code.
https://www.drupal.org/node/2023007 This issue talks about setting minimum. We should have an option for maximum also. I will see if I can create a patch for this.