Allows the Chosen jQuery script settings for Drop Down and Multi-Select fields to be modified when the “Enable enhanced user interface” is checked. Fires when the form is loaded and has a field using Chosen.
The Chosen script options object. Additional documentation can be found in the Chosen 1.1.0 release.
- allow_single_deselect bool
When set to true on a single select, Chosen adds a UI element which selects the first element (if it is blank).
When set to true, Chosen will not display the search field (single selects only).
Hide the search input on single selects if there are fewer than (n) options.
By default, searching will match on any word within an option tag. Set this option to false if you want to only match on the entire text of an option tag.
When set to true, Chosen will grab any classes on the original select field and add them to Chosen’s container div.
Limits how many options the user can select. When the limit is reached, the chosen:maxselected event is triggered.
The text to be displayed when no matching results are found. The current search is shown at the end of the text (e.g., No results match “Bad Search”).
The text to be displayed as a placeholder when no options are selected for a multiple select.
The text to be displayed as a placeholder when no options are selected for a single select.
By default, Chosen’s search matches starting at the beginning of a word. Setting this option to true allows matches starting from anywhere within a word. This is especially useful for options that include a lot of special characters or phrases in ()s and s.
By default, pressing delete/backspace on multiple selects will remove a selected choice. When false, pressing delete/backspace will highlight the last choice, and a second press deselects it.
The width of the Chosen select box. By default, Chosen attempts to match the width of the select box you are replacing. If your select is hidden when Chosen is instantiated, you must specify a width or the select will show up with a width of 0.
By default, Chosen includes disabled options in search results with a special styling. Setting this option to false will hide disabled results and exclude them from searches.
By default, Chosen includes selected options in search results with a special styling. Setting this option to false will hide selected results and exclude them from searches.
- allow_single_deselect bool
Note: this is for multiple selects only. In single selects, the selected result will always be displayed.
The jQuery element object.
This example uses the gform_pre_render filter to load the hook. This example limits the number of items which may be selected in a multi-select field.
This example shows how you can configure chosen to use a percentage based width.
This hook should be placed between script tags in an HTML field on your form or you may use the gform_pre_render hook to echo the script block to the page.
This filter is located in “gravityforms.js”