Log validation errors

Hi all,

I want to log the validation errors encountered by the system, like incorrect username-password combination. How can I do that?

I suggest to implement a validator that validates what you need,

logs a message if nessesary and always returns true.

Take a look at the CModel.afterValidate() method:




protected function afterValidate()

{

    parent::afterValidate();

    if ($this->hasErrors())

    {

        // your code there...

    }

}



Thanks, Andy. I used your suggestion :)





    //this will log the error action in the database

    protected function afterValidate() {

        parent::afterValidate();

        if ($this->hasErrors()) {

            log_errors($this->getErrors());

        }

    }



where log_errors is a function which will process the caught validation.