Where Is Validate() Method Used In Cformmodel Controllers?

i know the roles() method of CActiveRecord controllers type (for example PostController) is used in the following methods:

PostController->save() calls CModel->validate() calls CModel->getValidators() calls CModel->createValidators() calls CModel->roles()

but in CFormModel controllers type (for example LoginForm) Where is validate() method used? i mean which method would call it in CFormModel controllers?

You would call it to ensure that the user’s input passes the rules you’ve specified in your rules() method. Your action will contain code that looks something like this:

    $model = new YourFormModel;

    if (isset($_POST['YourFormModel']))


        $model->attributes = $_POST['YourFormModel'];

        if ($model->validate())


            // Set a flash message / redirect etc here



Thank you Keith. your answer is useful and You’re fast to answer questions. :) thank you man.