PHP Класс kartik\select2\Select2

См. также: https://github.com/select2/select2
С версии: 1.0
Автор: Kartik Visweswaran ([email protected])
Наследование: extends kartik\base\InputWidget
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$accesskey Implements open selector with accesskey
$addon addon to prepend or append to the Select2 widget - prepend: _array_|_string_, the prepend addon configuration. If set as a string will be rendered as is. If set as an array, the following properties can be set: - content: _string_, the prepend addon content. - asButton: _boolean, whether the addon is a button or button group. Defaults to false. - append: _array_|_string_, the append addon configuration. If set as a string will be rendered as is. If set as an array, the following properties can be set: - content: _string_, the append addon content. - asButton: _boolean, whether the addon is a button or button group. Defaults to false. - groupOptions: _array_, HTML options for the input group - contentBefore: _string_, content placed before addon - contentAfter: _string_, content placed after addon
$changeOnReset whether to trigger change for Select2 input on form reset so the Select2 value is rightly reset.
$data array the option data items. The array keys are option values, and the array values are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, an option group will be generated whose label is the key associated with the sub-array. If you have a list of data models, you may convert them into the format described above using [[ArrayHelper::map()]].
$hideSearch whether to hide the search control and render it as a simple select.
$initValueText
$language the locale ID (e.g. 'fr', 'de') for the language to be used by the Select2 Widget. If this property not set, then the current application language will be used.
$maintainOrder whether to maintain the order of tag / option selected for a multiple select
$options the HTML attributes for the input tag. The following options are important: - multiple: _boolean_, whether multiple or single item should be selected. Defaults to false. - placeholder: _string_, placeholder for the select item.
$pluginName the name of the jQuery plugin
$showToggleAll whether to show the toggle all button for selection all options in a multiple select.
$size Size of the Select2 input, must be one of the [[Select2::LARGE]], [[Select2::MEDIUM]] or [[Select2::SMALL]].
$theme the theme name to be used for styling the Select2.
$toggleAllSettings the toggle all button settings for selecting/unselecting all the options. This is applicable only for multiple select. The following array key properties can be set: - selectLabel: _string_, the markup to be shown to select all records. Defaults to: Select all. - unselectLabel: _string_, the markup to be shown to unselect all records. Defaults to: Unselect all. - selectOptions: _array_, the HTML attributes for the container wrapping the select label. Defaults to []. - unselectOptions: _array_, the HTML attributes for the container wrapping the unselect label. Defaults to []. - options: _array_, the HTML attributes for the toggle button container. Defaults to: ['class' => 's2-togall-button'].

Защищенные свойства (Protected)

Свойство Тип Описание
$_inbuiltThemes list of inbuilt themes
$_msgCat
$_s2OptionsVar the variable that will store additional options for Select2 to add enhanced features after the plugin is loaded and initialized. This variable name will be stored as a data attribute data-s2-options within the base select input options.

Открытые методы

Метод Описание
registerAssetBundle ( ) Registers the asset bundle and locale
registerAssets ( ) Registers the client assets for Select2 widget.
renderWidget ( ) Initializes and renders the widget
run ( )

Защищенные методы

Метод Описание
embedAddon ( string $input ) : string Embeds the input group addon
initPlaceholder ( ) Initializes the placeholder for Select2
parseBool ( mixed $var ) : yii\web\JsExpression Parses the variable for boolean value and returns a right JS expression
renderInput ( ) Renders the source Input for the Select2 plugin. Graceful fallback to a normal HTML select dropdown or text input - in case JQuery is not supported by the browser
renderToggleAll ( ) Initializes and render the toggle all button

Описание методов

embedAddon() защищенный Метод

Embeds the input group addon
protected embedAddon ( string $input ) : string
$input string
Результат string

initPlaceholder() защищенный Метод

Initializes the placeholder for Select2
protected initPlaceholder ( )

parseBool() защищенный статический Метод

Parses the variable for boolean value and returns a right JS expression
protected static parseBool ( mixed $var ) : yii\web\JsExpression
$var mixed the variable value to parse
Результат yii\web\JsExpression

registerAssetBundle() публичный Метод

Registers the asset bundle and locale
public registerAssetBundle ( )

registerAssets() публичный Метод

Registers the client assets for Select2 widget.
public registerAssets ( )

renderInput() защищенный Метод

Renders the source Input for the Select2 plugin. Graceful fallback to a normal HTML select dropdown or text input - in case JQuery is not supported by the browser
protected renderInput ( )

renderToggleAll() защищенный Метод

Initializes and render the toggle all button
protected renderToggleAll ( )

renderWidget() публичный Метод

Initializes and renders the widget
public renderWidget ( )

run() публичный Метод

public run ( )

Описание свойств

$_inbuiltThemes защищенное статическое свойство

list of inbuilt themes
protected static $_inbuiltThemes

$_msgCat защищенное свойство

protected $_msgCat

$_s2OptionsVar защищенное свойство

the variable that will store additional options for Select2 to add enhanced features after the plugin is loaded and initialized. This variable name will be stored as a data attribute data-s2-options within the base select input options.
protected $_s2OptionsVar

$accesskey публичное свойство

Implements open selector with accesskey
public $accesskey

$addon публичное свойство

addon to prepend or append to the Select2 widget - prepend: _array_|_string_, the prepend addon configuration. If set as a string will be rendered as is. If set as an array, the following properties can be set: - content: _string_, the prepend addon content. - asButton: _boolean, whether the addon is a button or button group. Defaults to false. - append: _array_|_string_, the append addon configuration. If set as a string will be rendered as is. If set as an array, the following properties can be set: - content: _string_, the append addon content. - asButton: _boolean, whether the addon is a button or button group. Defaults to false. - groupOptions: _array_, HTML options for the input group - contentBefore: _string_, content placed before addon - contentAfter: _string_, content placed after addon
public $addon

$changeOnReset публичное свойство

whether to trigger change for Select2 input on form reset so the Select2 value is rightly reset.
public $changeOnReset

$data публичное свойство

the option data items. The array keys are option values, and the array values are the corresponding option labels. The array can also be nested (i.e. some array values are arrays too). For each sub-array, an option group will be generated whose label is the key associated with the sub-array. If you have a list of data models, you may convert them into the format described above using [[ArrayHelper::map()]].
public array $data
Результат array

$hideSearch публичное свойство

whether to hide the search control and render it as a simple select.
public $hideSearch

$initValueText публичное свойство

public $initValueText

$language публичное свойство

the locale ID (e.g. 'fr', 'de') for the language to be used by the Select2 Widget. If this property not set, then the current application language will be used.
public $language

$maintainOrder публичное свойство

whether to maintain the order of tag / option selected for a multiple select
public $maintainOrder

$options публичное свойство

the HTML attributes for the input tag. The following options are important: - multiple: _boolean_, whether multiple or single item should be selected. Defaults to false. - placeholder: _string_, placeholder for the select item.
public $options

$pluginName публичное свойство

the name of the jQuery plugin
public $pluginName

$showToggleAll публичное свойство

whether to show the toggle all button for selection all options in a multiple select.
public $showToggleAll

$size публичное свойство

Size of the Select2 input, must be one of the [[Select2::LARGE]], [[Select2::MEDIUM]] or [[Select2::SMALL]].
public $size

$theme публичное свойство

the theme name to be used for styling the Select2.
public $theme

$toggleAllSettings публичное свойство

the toggle all button settings for selecting/unselecting all the options. This is applicable only for multiple select. The following array key properties can be set: - selectLabel: _string_, the markup to be shown to select all records. Defaults to: Select all. - unselectLabel: _string_, the markup to be shown to unselect all records. Defaults to: Unselect all. - selectOptions: _array_, the HTML attributes for the container wrapping the select label. Defaults to []. - unselectOptions: _array_, the HTML attributes for the container wrapping the unselect label. Defaults to []. - options: _array_, the HTML attributes for the toggle button container. Defaults to: ['class' => 's2-togall-button'].
public $toggleAllSettings