Autocomplete::className(), 'attributes' => [ 'repeat' => [['preview', 'text', false, 5, true, '...']], ] ] ]; } /** * @inheritdoc */ public function rules() { return [ [['lang_id', 'category_id'], 'integer'], [['text', 'name'], 'required'], [['text', 'preview', 'seo_url', 'name', 'meta_title', 'meta_descr', 'meta_keywords', 'h1_tag', 'tags'], 'string'], ['seo_url', function($attribute, $params) { $pattern = "/^[a-zA-Z\d_-]+$/"; if(!preg_match($pattern, $this->$attribute)) { $this->addError($attribute, Yii::t('app', "Pattern doesn't match.")); } }] ]; } /** * @inheritdoc */ public function attributeLabels() { return [ 'id' => Yii::t('app', 'ID'), 'lang_id' => Yii::t('app', 'Lang ID'), 'category_id' => Yii::t('app', 'Category ID'), 'text' => Yii::t('app', 'Text'), 'preview' => Yii::t('app', 'Preview'), 'seo_url' => Yii::t('app', 'Seo Url'), 'name' => Yii::t('app', 'Name'), 'meta_title' => Yii::t('app', 'Meta Title'), 'meta_descr' => Yii::t('app', 'Meta Descr'), 'meta_keywords' => Yii::t('app', 'Meta Keywords'), 'h1_tag' => Yii::t('app', 'H1 Tag'), 'tags' => Yii::t('app', 'Tags'), ]; } /** * @return \yii\db\ActiveQuery */ public function getCategory() { return $this->hasOne(ArticleCategory::className(), ['id' => 'category_id']); } /** * @return \yii\db\ActiveQuery */ public function getLang() { return $this->hasOne(Language::className(), ['language_id' => 'lang_id']); } }