Пример #1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Tag::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'created_at' => $this->created_at, 'created_by' => $this->created_by, 'updated_at' => $this->updated_at, 'updated_by' => $this->updated_by]);
     $query->andFilterWhere(['like', 'name', $this->name]);
     $query->andFilterWhere(['like', 'slug', $this->slug]);
     $query->andFilterWhere(['like', 'color', $this->color]);
     if (!empty($this->type)) {
         $query->filterType($this->type);
     }
     return $dataProvider;
 }
Пример #2
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     echo $this->form->field($this->model, 'tagIds')->widget(Select2::className(), ['data' => ArrayHelper::map(Tag::find()->filterType($this->model->getTagAssociationType())->all(), 'id', 'name'), 'options' => ['placeholder' => Yii::t('jlorente/tagable', 'Select a tag')], 'pluginOptions' => ['multiple' => true, 'allowClear' => true, 'tags' => true]]);
 }
Пример #3
0
 /**
  * @inheritdoc
  */
 public function run()
 {
     echo Html::tag('div', Select2::widget(['model' => $this->model, 'attribute' => 'tags', 'data' => ArrayHelper::map(Tag::find()->filterType($this->model->getTagAssociationType())->orderBy('slug ASC')->all(), 'slug', 'name'), 'language' => 'es', 'options' => ['placeholder' => Yii::t('jlorente/tagable', 'Filter by tag') . '...', 'data-url' => $this->url], 'pluginOptions' => ['allowClear' => true, 'multiple' => false]]), ['class' => 'tag-select-filter']);
 }