
Elegido widget de selección (hermoso, lista desplegable funcional)
skeeks/yii2-widget-chosen
-
Семенов Александр
- /
- Otros
- /
- hace 5 años
- /
- /
- 5849
- /
- 0
Tiempo de publicación: miércoles, 24 de junio de 2015 (hace 5 años)
Creado por: Семенов Александр Сергеевич
Categoría: Otros
Versión actual:
1 ene. 1970 3:00:00 (hace 51 años)
Packagist: skeeks/yii2-widget-chosen
: https://github.com/skeeks-semenov/yii2-widget-chosen
:
Tipo: Компонент
<? php usar skeeks \ widget \ chosen \ Chosen; ?> <? = Elegido :: widget ([ 'modelo' => $ modelo, 'atributo' => 'selectable_attr', 'items' => [1 => 'First item', 2 => 'Second item', 3 => 'Third item'], 'multiple' => true, ]);?> <? = $ form-> campo ($ modelo, 'selectable_attr') -> widget ( Elegido :: className (), [ 'items' => [1 => 'First item', 2 => 'Second item', 3 => 'Third item'], 'disableSearch' => 5, // La entrada de búsqueda se deshabilitará mientras haya menos de 5 elementos 'clientOptions' => [ 'search_contains' => true, 'single_backstroke_delete' => false, ] ]);?>
Chosen + Bootstrap 3 + Yii2
Credits
Chosen http://harvesthq.github.io/chosen/
Chosen Bootstrap Look & Feel https://github.com/dbtek/chosen-bootstrap (with my style fixes)
Installation
The preferred way to install this extension is through composer.
Either run
php composer.phar require "skeeks/yii2-widget-chosen" "*"
or add
"skeeks/yii2-widget-chosen" : "*"
to the require
section of your application’s composer.json
file.
Usage
With a model
<?php
use skeeks\widget\chosen\Chosen;
?>
<?= Chosen::widget([
'model' => $model,
'attribute' => 'selectable_attr',
'items' => [1 => 'First item', 2 => 'Second item', 3 => 'Third item'],
'multiple' => true,
]);?>
<?= $form->field($model, 'selectable_attr')->widget(
Chosen::className(), [
'items' => [1 => 'First item', 2 => 'Second item', 3 => 'Third item'],
'disableSearch' => 5, // Search input will be disabled while there are fewer than 5 items
'clientOptions' => [
'search_contains' => true,
'single_backstroke_delete' => false,
],
]);?>
Without a model
<?php
use skeeks\widget\chosen\Chosen;
?>
<?= Chosen::widget([
'name' => 'ChosenTest',
'value' => 3,
'items' => [1 => 'First item', 2 => 'Second item', 3 => 'Third item'],
'allowDeselect' => false,
'disableSearch' => true, // Search input will be disabled
'clientOptions' => [
'search_contains' => true,
'max_selected_options' => 2,
],
]);?>
To override default placeholder strings you can add translated messages for Select an option
(single select) and Select some options
(multiple select) to your application message file. By default widget will use ‘app’ category to translate this strings, but you can set your own category by changing translateCategory
option in widget configuration. For example, you can write this in application config file:
<?php
\Yii::$container->set('skeeks\widget\chosen\Chosen', [
'translateCategory' => 'my-app',
]);
Also you can override placeholder text when invoking widget (it can be useful for selects with small width):
<?php
use skeeks\widget\chosen\Chosen;
?>
<?= Chosen::widget([
'name' => 'ChosenTest',
'value' => 3,
'items' => [1 => 'First item', 2 => 'Second item', 3 => 'Third item'],
'placeholder' => 'Select',
]);?>
SkeekS CMS (Yii2) — quickly, easily and effectively!
skeeks.com | cms.skeeks.com
CHANGELOG
1.2.2
- Fixed
1.2.1
- Updating choosen to 1.8.2
1.2.0
- Updating choosen to 1.8
1.1.0
- Updating library
dev-master — 1 ene. 1970 3:00:00 (hace 51 años)
1.2.2.2 — 1 ene. 1970 3:00:00 (hace 51 años)
1.2.2.1 — 1 ene. 1970 3:00:00 (hace 51 años)
1.2.2 — 1 ene. 1970 3:00:00 (hace 51 años)
1.2.1 — 1 ene. 1970 3:00:00 (hace 51 años)
1.2.0 — 1 ene. 1970 3:00:00 (hace 51 años)
1.1.0 — 1 ene. 1970 3:00:00 (hace 51 años)
1.0.4 — 1 ene. 1970 3:00:00 (hace 51 años)
1.0.5 — 1 ene. 1970 3:00:00 (hace 51 años)
1.0.3 — 1 ene. 1970 3:00:00 (hace 51 años)
1.0.2 — 1 ene. 1970 3:00:00 (hace 51 años)
1.0.1 — 1 ene. 1970 3:00:00 (hace 51 años)
1.0.0 — 1 ene. 1970 3:00:00 (hace 51 años)
Стандартная установка:
Добавьте composer.json файл вашего проекта:
"skeeks/yii2-widget-chosen": "*"
Запустите обновление зависимостей
todos los comentarios (0)