Closed (fixed)
Project:
Chosen
Version:
4.0.x-dev
Component:
Documentation
Priority:
Major
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
25 Jun 2024 at 18:22 UTC
Updated:
17 May 2026 at 10:10 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
nagy.balint commentedHi!
Can you provide more details?
For me at least on 4.0.x if the cardinality is 5 let's say, then I cannot select more than 5 items, the dropdown does not come up.
And it is already using the "max_selected_options" of the chosen library.
Comment #3
matslats commentedThanks for asking.
My field is actually a basefield, not a field API field. I don't know if that makes a difference.
That's all the extra information I can think of right now.
Comment #4
nagy.balint commentedMaybe in that case it will miss the required attribute and data, which is there on field API fields.
Comment #5
matslats commentedOn src/ChosenFormRender.php line 73, the #bundle property is required but base fields have no bundle.
if (isset($element['#entity_type']) && isset($element['#bundle']) && isset($element['#field_name'])) {However, inside that if block, the case of no bundles is handled
So it looks like a simple bug.
Replace
if (isset($element['#entity_type']) && isset($element['#bundle']) && isset($element['#field_name'])) {with
if (isset($element['#entity_type']) && isset($element['#field_name'])) {Comment #6
matslats commentedAnd here's the patch
Comment #7
vensiresIt's a really small change and seems to fix the issue correctly. Setting as RTBC.
Comment #8
nagy.balint commentedThe patch seems to be wrong here, since
FieldConfig::loadByName($element['#entity_type'], $element['#bundle'], $element['#field_name']);
still uses bundle, maybe something is missing from the patch.
Comment #10
nagy.balint commented