I am using a dynamic model in my base yii2 application.
Below is the code for my dynamic model.
$model = new \yii\base\DynamicModel([
'role', 'from_rm', 'to_rm', 'user1_subdistrcts'
]);
$model->addRule(['user1_subdistrcts', 'role'], 'required', ['message' => "Please select this field."])
->addRule(['from_rm'], 'checkRm');
here I am ready for the custom validation function 'checkRm' form from_rmfield I also defined the function checkRm as follows:
public function checkRm($from_rm, $params)
{
$this->addError($from_rm, 'Please Select Regional Manager.');
}
But when I submit the form, I get an error. Class CheckRm not found.
Now please help how to use custom validation in a dynamic model.
I also tried the conditions whenand whenClient, but they also do not work
source
share