soless / yii2-jquery-tageditor-widget
Widget for a powerful and lightweight tag editor plugin for jQuery with available tags select buttons
Installs: 184
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:yii2-extension
Requires
- bower-asset/jquery-tag-editor: *
- yiisoft/yii2: ~2.0.0
README
Widget for tags adding. Based on https://goodies.pixabay.com/jquery/tag-editor/demo.html
Installation The preferred way to install this extension is through composer.
composer require --prefer-dist soless/yii2-jquery-tageditor-widget "*"
usage:
<?php echo $form->field($model, 'selectedTags')->widget('soless\tageditor\TagEditorWidget', [ 'availableTags' => ['firstTag', 'secondTag', 'thirdTag', ], 'tagEditorOptions' => [ 'forceLowercase' => false, 'autocomplete' => [ 'source' => \yii\helpers\Url::toRoute(['/tag/suggest']) ], ] ]) ?>
app\controllers\TagController (suggest action example) :
public function actionSuggest($term) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return \yii\helpers\ArrayHelper::getColumn( \common\models\Tag::find() ->select('title') ->filterWhere(['like', 'title', $term.'%', false]) ->all(), 'title' ); }