I am taking over a project that another developer finished. It was created using Yii, which I’m not very familiar with.
I would like to be able to see when users submitting forms on my site run into any validation errors. Is there anyway to easily log this information so I can see any errors users receive, along with the data they entered which triggered the error?
in your model for login you can add:
public function onAfterValidate($event)
u main config,in log, you can add this route, so you will get email on error
For the second part, did you mean in /protected/config/main.php?
Minor note: I’d not override onAfterValidate() but afterValidate(). The latter was built for this purpose. If you don’t do that, your event may not trigger correctly anymore. This could matter if you e.g. attach a behavior which tries to attach another handler to this event. And you should call parent::beforeValidate() from your override method.
I’m not really familiar with Yii, so I’m not sure what you mean.
Can you please give me an example of how to make those changes? I tried making the updates that nermin,i suggested, but I never received any emails.
Maybe try to log into a file first (just to make sure, it’s not an email transport problem):
I also recommend to read the guide section about logging because you should learn to help yourself
I was able to get the logging to work to a file, but not email. That’s good enough.