My form fails to submit if I have a value other than RE in my account field. The account field is a radio button value.
public function rules()
{
return [
['username', 'filter', 'filter' => 'trim'],
['username', 'required'],
['username', 'email'],
['username', 'unique', 'targetClass' => '\app\models\User', 'message' => 'This email address has already been taken.'],
['name', 'filter', 'filter' => 'trim'],
['name', 'required'],
['name', 'string', 'min' => 2, 'max' => 255],
['password', 'required'],
['password', 'string', 'min' => 6],
['account', 'required'],
['account', 'string','min' => 1, 'max' => 2],
['license', 'required', 'when' => function($model) {
return $model->account == 'RE';
}],
['license', 'string','min' => 1, 'max' => 255],
];
}
I am missing something with conditional validation?