title: Yii2 tagging 2amigos is not saving tags to the table
body: <p>I am trying to implement tagged articles for my new small CMS written with yii2.</p>
  
  <p>This is what i have tried <a href="https://forum.yiiframework.com/t/how-to-create-tags-for-posts-in-yii2/123890" rel="nofollow noreferrer">https://forum.yiiframework.com/t/how-to-create-tags-for-posts-in-yii2/123890</a></p>
  
  <p>Everything is working the tagging machanism is fetching data from the tag table but it is not saving data to the table tag_assign.</p>
  
  <p>This is my form.</p>
  
  <pre><code>&lt;?php
  
  use yii\helpers\Html;
  use yii\widgets\ActiveForm;
  //Using for Wysiwig editor
  use dosamigos\ckeditor\CKEditor;
  //Using for Tagging
  use dosamigos\selectize\SelectizeTextInput;
  
  /* @var $this yii\web\View */
  /* @var $model common\models\Articles */
  /* @var $form yii\widgets\ActiveForm */
  ?&gt;
  
  &lt;div class="articles-form"&gt;
      &lt;?php $form = ActiveForm::begin(); ?&gt;
  
      &lt;?= $form-&gt;field($model, 'title')-&gt;textInput(['maxlength' =&gt; true]) ?&gt;
  
      &lt;?= $form-&gt;field($model, 'content')-&gt;widget(CKEditor::className(), [
          'options' =&gt; ['height' =&gt; 800],
          'preset' =&gt; 'basic',
          'clientOptions' =&gt; ['height' =&gt; 400]
      ]) ?&gt;
  
  
      &lt;?= $form-&gt;field($model, 'tags')-&gt;widget(SelectizeTextInput::className(), [
      // calls an action that returns a JSON object with matched
      // tags
        'loadUrl' =&gt; ['tag/list'],
        'options' =&gt; ['class' =&gt; 'form-control'],
        'clientOptions' =&gt; [
            'plugins' =&gt; ['remove_button'],
            'valueField' =&gt; 'name',
            'labelField' =&gt; 'name',
            'searchField' =&gt; ['name'],
            'create' =&gt; true,
        ],
      ])-&gt;hint('Use commas to separate tags') ?&gt;
  
  
      &lt;?= $form-&gt;field($model, 'date')-&gt;textInput() ?&gt;
  
      &lt;div class="form-group"&gt;
          &lt;?= Html::submitButton('Save', ['class' =&gt; 'btn btn-success']) ?&gt;
      &lt;/div&gt;
  
      &lt;?php ActiveForm::end(); ?&gt;
  
  &lt;/div&gt;
  </code></pre>
  
  <p>And this is my tag model</p>
  
  <pre><code>&lt;?php
  
  namespace common\models;
  
  use Yii;
  use dosamigos\taggable\Taggable;
  /**
   * This is the model class for table "tags".
   *
   * @property int $id
   * @property string $frequency
   * @property string $name
   */
  class Tag extends \yii\db\ActiveRecord
  {
      /**
       * {@inheritdoc}
       */
      public static function tableName()
      {
          return 'tags';
      }
  
      /**
       * {@inheritdoc}
       */
      public function rules()
      {
          return [
              [['frequency', 'name'], 'required'],
              [['frequency'], 'string', 'max' =&gt; 500],
              [['name'], 'string', 'max' =&gt; 250],
          ];
      }
  
      /**
       * {@inheritdoc}
       */
      public function attributeLabels()
      {
          return [
              'id' =&gt; 'ID',
              'frequency' =&gt; 'Frequency',
              'name' =&gt; 'Name',
          ];
      }
  
      //For Tagging
      public function behaviors() {
          return [
              [
                  'class' =&gt; Taggable::className(),
              ],
          ];
      }
      public function findAllByName($name)
      {
          return Tag::find()-&gt;where('name LIKE :query')
                            -&gt;addParams([':query'=&gt;"%$name%"])
                            -&gt;all();
      }
  }
  </code></pre>
  
  <p>Tag controller.</p>
  
  <pre><code>&lt;?php
  
  namespace backend\controllers;
  
  use Yii;
  use common\models\Tag;
  use common\models\searchTag;
  use yii\web\Controller;
  use yii\web\NotFoundHttpException;
  use yii\filters\VerbFilter;
  use yii\web\Response;
  
  /**
   * TagController implements the CRUD actions for Tag model.
   */
  class TagController extends Controller
  {
      /**
       * {@inheritdoc}
       */
      public function behaviors()
      {
          return [
              'verbs' =&gt; [
                  'class' =&gt; VerbFilter::className(),
                  'actions' =&gt; [
                      'delete' =&gt; ['POST'],
                  ],
              ],
          ];
      }
  
      /**
       * Lists all Tag models.
       * @return mixed
       */
      public function actionIndex()
      {
          $searchModel = new searchTag();
          $dataProvider = $searchModel-&gt;search(Yii::$app-&gt;request-&gt;queryParams);
  
          return $this-&gt;render('index', [
              'searchModel' =&gt; $searchModel,
              'dataProvider' =&gt; $dataProvider,
          ]);
      }
  
      /**
       * Displays a single Tag model.
       * @param integer $id
       * @return mixed
       * @throws NotFoundHttpException if the model cannot be found
       */
      public function actionView($id)
      {
          return $this-&gt;render('view', [
              'model' =&gt; $this-&gt;findModel($id),
          ]);
      }
  
      /**
       * Creates a new Tag model.
       * If creation is successful, the browser will be redirected to the 'view' page.
       * @return mixed
       */
      public function actionCreate()
      {
          $model = new Tag();
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save()) {
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          }
  
          return $this-&gt;render('create', [
              'model' =&gt; $model,
          ]);
      }
      public function actionList($query)
      {
          $models = Tag::findAllByName($query);
          $items = [];
  
          foreach ($models as $model) {
              $items[] = ['name' =&gt; $model-&gt;name];
          }
          // We know we can use ContentNegotiator filter
          // this way is easier to show you here :)
          Yii::$app-&gt;response-&gt;format = Response::FORMAT_JSON;
  
          return $items;
      }
  
      /**
       * Updates an existing Tag model.
       * If update is successful, the browser will be redirected to the 'view' page.
       * @param integer $id
       * @return mixed
       * @throws NotFoundHttpException if the model cannot be found
       */
      public function actionUpdate($id)
      {
          $model = $this-&gt;findModel($id);
  
          if ($model-&gt;load(Yii::$app-&gt;request-&gt;post()) &amp;&amp; $model-&gt;save()) {
              return $this-&gt;redirect(['view', 'id' =&gt; $model-&gt;id]);
          }
  
          return $this-&gt;render('update', [
              'model' =&gt; $model,
          ]);
      }
  
      /**
       * Deletes an existing Tag model.
       * If deletion is successful, the browser will be redirected to the 'index' page.
       * @param integer $id
       * @return mixed
       * @throws NotFoundHttpException if the model cannot be found
       */
      public function actionDelete($id)
      {
          $this-&gt;findModel($id)-&gt;delete();
  
          return $this-&gt;redirect(['index']);
      }
  
      /**
       * Finds the Tag model based on its primary key value.
       * If the model is not found, a 404 HTTP exception will be thrown.
       * @param integer $id
       * @return Tag the loaded model
       * @throws NotFoundHttpException if the model cannot be found
       */
      protected function findModel($id)
      {
          if (($model = Tag::findOne($id)) !== null) {
              return $model;
          }
  
          throw new NotFoundHttpException('The requested page does not exist.');
      }
  }
  </code></pre>
  
  <p>And the articles </p>
  
  <pre><code>&lt;?php
  
  namespace common\models;
  
  use Yii;
  //For Taggable
  use dosamigos\taggable\Taggable;
  /**
   * This is the model class for table "articles".
   *
   * @property int $id
   * @property string $title
   * @property string $content
   * @property string $tags
   * @property string $date
   */
  class Articles extends \yii\db\ActiveRecord
  {
      //For taggable
      public function behaviors() {
         return [
             [
                 'class' =&gt; Taggable::className(),
             ],
         ];
     }
      /**
       * {@inheritdoc}
       */
      public static function tableName()
      {
          return 'articles';
      }
  
      /**
       * {@inheritdoc}
       */
      public function rules()
      {
          return [
              [['title', 'content', 'tags', 'date'], 'required'],
              [['content'], 'string'],
              [['date'], 'safe'],
              [['title', 'tags'], 'string', 'max' =&gt; 250],
          ];
      }
  
      /**
       * {@inheritdoc}
       */
      public function attributeLabels()
      {
          return [
              'id' =&gt; 'ID',
              'title' =&gt; 'Title',
              'content' =&gt; 'Content',
              'tags' =&gt; 'Tags',
              'date' =&gt; 'Date',
          ];
      }
      public function getTags()
      {
          return $this-&gt;hasMany(Tag::className(), ['id' =&gt; 'tag_id'])-&gt;viaTable('tag_assign', ['article_id' =&gt; 'id']);
      }
  
  }
  </code></pre>
  
  <p>What I am missing? How can I trouble shoot at least what is going wrong?</p>