[
['state', 'required', 'when' => function($model) {
return $model->role_id == '2';
}],
]
public function rules()
public function relations ()
array('attribute list', 'validator name', 'on'=>'scenario name', ...validation parameters...)
attribute list: specifies the attributes (separated by commas) to be validated;
array('test, configsArray' ,'safe'),