UserModel.php
Код: Выделить всё
public function behaviors()
{
//I use array_merge() because UserModel extends from another custom model.
return
array_merge(
parent::behaviors(),
[
MyBehavior::className(),
]
);
}
public function rules()
{
return
array_merge(
MyBehavior::theRules(),
[
list of UserModel rules...
]
);
Код: Выделить всё
class MyBehavior extends Behavior
{
public static function theRules()
{
return [
[['attr'],'file']
];
}
....
}
Подробнее здесь: https://stackoverflow.com/questions/425 ... n-behavior