示例#1
0
 /**
  * Validation rules
  * @return array
  */
 public function rules()
 {
     $rules = $this->_model->rules();
     $rules[] = ['tags', 'exist', 'targetClass' => Tag::className(), 'targetAttribute' => 'id', 'allowArray' => true];
     $rules['keyExists'] = ['key', 'unique', 'targetClass' => Post::className(), 'targetAttribute' => 'key', 'when' => function ($model) {
         return $model->key != $model->item->key;
     }];
     return $rules;
 }
示例#2
0
 public function getPost()
 {
     return $this->hasOne(Post::className(), ['id' => 'post_id']);
 }