Zum Inhalt springen
PHP Ecosystem
Explore

Selectize

Dieser Inhalt ist noch nicht in deiner Sprache verfügbar.

Selectize selects and text inputs for Yii models and forms

Bootstrap 5 styling, multiple values, remote JSON choices and lifecycle cleanup

Configure the consuming application’s plugins and asset aliases with the installation guide, then install the documented branch:

Terminal window
composer require --prefer-dist yii2-extensions/selectize:^0.2

The native asset manager installs the published frontend assets without Node.js or a JavaScript build. Keep an existing application manager when it already supplies those assets.

Place this in a Yii view and associate the input with a visible label:

use yii\helpers\Html;
use yii2\extensions\selectize\Selectize;
echo Html::label('Category', 'category');
echo Selectize::widget(
[
'name' => 'category',
'value' => 'yii',
'items' => ['php' => 'PHP', 'yii' => 'Yii'],
'options' => ['id' => 'category', 'prompt' => 'Choose a category'],
'clientOptions' => ['maxItems' => 1],
],
);

Item keys are submitted values. To bind a model attribute in an ActiveForm:

use yii2\extensions\selectize\Selectize;
echo $form->field($model, 'tags')
->widget(
Selectize::class,
[
'items' => ['php' => 'PHP', 'yii' => 'Yii'],
'options' => ['multiple' => true],
'clientOptions' => ['plugins' => ['remove_button']],
],
);

The model must validate tags as an array; browser options do not authorize submitted values. See model validation for cleared fields and rejected submissions.

Practical guides and examples for widget configuration, forms and remote choices.

The guides and the API reference generated from the PHPDoc in src/ are published at https://yii2-framework.github.io/docs/extensions/selectize/.

AI agents: read the documentation index and fetch the Markdown version of a page by appending index.md to its URL. The AI agents guide covers skill installation, client setup and verification.

The hosted documentation covers Yii 22.0. If it does not match the installed revision or is unavailable, use the repository guides, the skill source, the source PHPDoc and the changelog.

Follow on X Follow on Facebook Join our Subreddit Join on Telegram

License

The extension uses BSD-3-Clause. Bundled third-party JavaScript retains its Apache-2.0 and MIT terms; see the third-party runtime notices.