Download the PHP package cehojac/cmb-field-select2 without Composer
On this page you can find all versions of the php package cehojac/cmb-field-select2. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download cehojac/cmb-field-select2
More information about cehojac/cmb-field-select2
Files in cehojac/cmb-field-select2
Package cmb-field-select2
Short Description Select2 field type for CMB2
License GPL-2.0+
Homepage https://github.com/cehojac/cmb-field-select2
Informations about the package cmb-field-select2
CMB2 Field Type: Select2
Description
This plugin gives you two additional field types based on Select2:
- The
pw_select
field acts much like the defaultselect
field. However, it adds typeahead-style search allowing you to quickly make a selection from a large list - The
pw_multiselect
field allows you to select multiple values with typeahead-style search. The values can be dragged and dropped to reorder new items - The
pw_select_taxonomy
and - The
pw_multiselect_taxonomy
Installation
You can install this field type as you would a WordPress plugin:
- Download the plugin
- Place the plugin folder in your
/wp-content/plugins/
directory - Activate the plugin in the Plugin dashboard
Alternatively, you can include this field type within your plugin/theme. The path to front end assets (JS/CSS) can be filtered using pw_cmb2_field_select2_asset_path
. See an example where we load assets from the current active theme.
Usage
pw_select
- Select box with with typeahead-style search. Example:
pw_multiselect
- Multi-value select box with drag and drop reordering. Example:
Placeholder
You can specify placeholder text through the attributes array. Example:
Custom Select2 configuration and overriding default configuration options
You can define Select2 configuration options using HTML5 data-*
attributes. It's worth reading up on the available options over on the Select2 website. Example:
Helper functions
You may want to populate the options array dynamically. Common use cases include listing out posts and taxonomy terms. I've written a number of generic helper functions which can be used to return a CMB2 style array for both posts and terms.
Limitations/known issues
If you’d like to help out, pull requests are more than welcome!
- This field does not work well as a repeatable field within a repeatable group.
- Yoast SEO also loads Select2. Currently a version behind, there is an issue with the previous version of Select2 and it's ability to position the dropdown relative to the field.