Problem/Motivation

It would be useful if individual form elements could override the options passed to the Chosen library. For example, a select element whose items are all long_machine_names_with_underscores might want to force search_contains = TRUE.

This could be done if this line added to what was potentially already there rather than clobber:

  $element['#attached']['drupalSettings']['chosen'] = [

Steps to reproduce

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Issue fork chosen-3431221

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

joachim created an issue. See original summary.

vensires’s picture

Issue tags: +GreeceSpringSprint2024
christos diamantis’s picture

Version: 4.0.x-dev » 4.0.0
Status: Active » Needs review
StatusFileSize
new6.58 KB

Overrides the default placeholder, no_ results_text and search_contains options via the chosen_select field widget. It would be easy to add more option overrides, but maybe the form would get too big?

Status: Needs review » Needs work

The last submitted patch, 3: override_default_chosen_options-3431221.patch, failed testing. View results
- codesniffer_fixes.patch Interdiff of automated coding standards fixes only.

vensires’s picture

Version: 4.0.0 » 4.0.x-dev

vensires’s picture

Status: Needs work » Needs review

I have created a new MR with the changes from #3 above but for 4.0.x-dev version.
No further changes exist in my code.

PS: It seems that the tests are failing but I am not sure if they break due to this code or if they were already broken from the past; in the later case we should handle them in a different issue.

nagy.balint’s picture

Status: Needs review » Needs work

I think they fail only cause of missing schema.

So the extra fields on the widget requires the schema to be defined in the chosen_field module.

vensires’s picture

  • nagy.balint committed b61d802d on 5.0.x
    feat: #3431221 allow form elements to override Chosen library options...
nagy.balint’s picture

Status: Needs work » Fixed

Thanks!

Fixed in 5.x

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.