This project is not covered by Drupal’s security advisory policy.
Chosen Ajax uses the Chosen jQuery plugin and a modified version of Ajax Chosen to make your autocomplete fields more user-friendly.
It improves Entity Reference fields by hiding brackets and id to the user.
Dependencies
- Chosen module.
How to use in Field UI
- Create (or edit an existing field) that can use Autocomplete as widget such as Entity Reference or Term reference
- Go to the field settings and check Apply Chosen to this field.
- Go to the Chosen section and change texts if needed.
- If the field is an Entity Reference, check the option Fix display.
- Most probably you don't need to change the Advanced settings unless you know what you're doing.
How to use with Form API
...
$form['my_chosen_ajax_field'] = array(
'#title' => 'My chosen ajax field',
'#type' => 'textfield',
'#autocomplete_path' => 'path/to/options',
'#chosen' => TRUE,
'#chosen_ajax' => array(
// You can skip these options if default values are ok.
'options' => array(
'placeholder_text' => t('Select a value'),
'typing_placeholder' => t('You need to type more'),
'searching_placeholder' => t('Searching for'),
),
// Set this values to change output.
// Field's value is automatically passed as last argument.
'value callback' => 'my_fix_display_func',
// Only if it's necessary.
'value arguments' => array('some_arg'),
),
);
...
IMPORTANT NOTES
- If the Fix display option does not work for Entity Reference fields, make sure your pattern is
/(.+) \((\d+)\)/and NOT/\"(.+) \((\d+)\)\"/(they removed quotes at some point).
Project information
Seeking co-maintainer(s)
Maintainers are looking for help reviewing issues.Maintenance fixes only
Considered feature-complete by its maintainers.119 sites report using this module
- Created by cristhian on , updated
This project is not covered by the security advisory policy.
Use at your own risk! It may have publicly disclosed vulnerabilities.
