I’ve been trying to add a custom validation, but it keeps throwing the error below.
This is the code I’m using inside the actionCreate() of my Controller.
$uniqueValidator = new CUniqueValidator;
$uniqueValidator->attributeName = 'phone_mobile';
$uniqueValidator->validate($model, array('phone'));
Now, I know that the same thing can be achieved using the code below in rules(),
array('phone', 'unique', 'attributeName'=>'phone_mobile'),
It works smoothly if I do it using rules(). How to do it without using rules()? What is the correct methods to use these validator classes explicitly?