Reputation:
I have 3 scenarios in the model in the rules() method and I want to use a rule on 2 scenarios ,
[['username', 'email', 'password'], 'required', 'on' => self::SCENARIO_REGISTER]
I read the guide , haven't find a way to bind a rule to 2 scenarios at the same time? Is there any way to do that ?
Upvotes: 12
Views: 4232
Reputation: 33538
You can pass an array to on
:
[['username', 'email', 'password'], 'required', 'on' => [self::SCENARIO_REGISTER, self::SCENARIO_OTHER]]
Upvotes: 17