joomla/joomla-cms — pull request #3721 by Bakual (2014-06-04 08:19:08+00:00)
Title: Changing list formfields to use a default class "advancedSelect" for Chosen support

This is an updated and bit improved version of #1620.
Originally it started as a way to automatically disable Chosen when there are a lot of options. It expanded a bit from there.
There are also other PRs with have different ways proposed to solve similar issues: #2018, #1609

See also Feature Tracker:
http://joomlacode.org/gf/project/joomla/tracker/?action=TrackerItemEdit&tracker_item_id=31514

### Issue
Chosen has performance issues when facing a huge amount of options. Since the menu item view (like most views) use `JHtml::_('formbehavior.chosen', 'select');` to load Chosen on every ``, this can break the creation of menu items.
This PR makes use of the default behaviour of `JHtml::_('formbehavior.chosen');` which triggers on the class `.advancedSelect`.

### Proposed Solution
This PR will do a few things:
- Changing the `list`, `groupedlist`, `accesslevel` and `componentlayout` formfields so it defaults to the class "advancedSelect" if no class is given. Currently there is no default at all.
- Changing the `list` formfield so it removes this class if there are more than 10'000 options.
- Changing the call `JHtml::_('formbehavior.chosen', 'select');` to use the default `JHtml::_('formbehavior.chosen');` in the menu item view.

For now, the scope is only the menu item edit form, however it would be possible to expand it to other places as well if we decide to follow that route. Especially if we use a default class within the fields, we don't have to edit 100+ XML files to add the class there.

If a developer decides he doesn't want to use Chosen for a specific field, he could just add a random class to the field in the XML and Chosen wouldn't be loaded anymore.

There may be better ideas of course :smile:

### Testing
* Make sure the menu item edit screen looks the same before and after the patch. Especially the dropdown lists should look and behave the same (using Chosen).
* Try testing with some big data, like 10'000 categories and check that the category selection doesn't use chosen anymore.