GithubHelp home page GithubHelp logo

yii2-tagit-widget's Introduction

yii2-tagit-widget

https://github.com/aehlke/tag-it

composer.json

"require": {
    "xj/yii2-tagit-widget": "*"
},

In View

//work with ActiveForm
$form->field($model, 'tags')->widget(\xj\tagit\Tagit::className(), [
    'clientOptions' => [
        'tagSource' => Url::to(['tag/get-autocomplete']),
        'autocomplete' => [
            'delay' => 200,
            'minLength' => 1,
        ],
        'singleField' => true,
        'beforeTagAdded' => new JsExpression(<<<EOF
function(event, ui){
    if (!ui.duringInitialization) {
        console.log(event);
        console.log(ui);
    }
}
EOF
),
    ],
]);

//work with hidden input
echo yii\helpers\Html::hiddenInput('mytag', '', ['id' => 'myTagId']);
echo Tagit::widget([
    'renderTag' => false,
    'id' => 'myTagId',
    'name' => 'mytag',
    'value' => ['a', 'b'],
    'clientOptions' => [
        'availableTags' => ['aaa', 'bbb']
    ]
]);

//work with hidden input (input init value)
echo yii\helpers\Html::hiddenInput('mytag2', 'a,b,c,d', ['id' => 'myTagId2']);
echo Tagit::widget([
    'renderTag' => false,
    'id' => 'myTagId2',
    'name' => 'mytag2',
    'clientOptions' => [
        'availableTags' => ['aaa', 'bbb']
    ]
]);

//auto render with autocomplete
echo Tagit::widget([
    'id' => 'myTagId3',
    'name' => 'mytag3',
    'clientOptions' => [
        'tagSource' => Url::to(['tag/get-autocomplete']),
        'autocomplete' => [
            'delay' => 0,
            'minLength' => 1,
        ],
    ]
]);

Assets

xj\tagit\TagitAsset::register($this);

yii2-tagit-widget's People

Contributors

xjflyttp avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

yii2-tagit-widget's Issues

yiisoft/yii2-jui required?

I tried yii2-tagit-widget and ran into a problem.

Error Class yii\jui\JuiAsset does not exist

So I had to install jui\JuiAsset

composer require --prefer-dist yiisoft/yii2-jui
and everithing worked

I do not know, if jui\JuiAsset should allready be included in yii2 ?
Maybe the hint about requiremend of jui\JuiAsset should be included in README.md

I use composer create-project --prefer-dist yiisoft/yii2-app-advanced yii_advanced

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.