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?
Page 1 of 1
Anyway To Log Form Validation Errors?
#2
Posted 28 January 2013 - 03:52 PM
in your model for login you can add:
u main config,in log, you can add this route, so you will get email on error
public function onAfterValidate($event)
{
if($this->hasErrors())
{
Yii::log(CVarDumper::dumpAsString($this->getErrors()),'error','application.model.login');
}
return true;
}
u main config,in log, you can add this route, so you will get email on error
array(
'class'=>'CEmailLogRoute',
'levels'=>'error',
'categories'=>'application.model.login',
'emails'=>'your@email',
),
#3
Posted 28 January 2013 - 04:24 PM
Thanks!
For the second part, did you mean in /protected/config/main.php?
For the second part, did you mean in /protected/config/main.php?
#5
Posted 29 January 2013 - 03:40 PM
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.
#6
Posted 29 January 2013 - 03:51 PM
Hi Mike,
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.
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.
#7
Posted 30 January 2013 - 03:09 AM
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
http://www.yiiframew.../topics.logging
array(
'class'=>'CFileLogRoute',
),I also recommend to read the guide section about logging because you should learn to help yourself
http://www.yiiframew.../topics.logging
#8
Posted 30 January 2013 - 12:58 PM
I was able to get the logging to work to a file, but not email. That's good enough.
I've read through the docs on logging, but I cannot seem to figure out how to make it show an error when a JavaScript form error occurs. Is this possible? The only thing I could get to work is logging server-side errors or record when an ajax request is made, but I can't see the errors that the visitor gets when trying to fill out a form.
I've read through the docs on logging, but I cannot seem to figure out how to make it show an error when a JavaScript form error occurs. Is this possible? The only thing I could get to work is logging server-side errors or record when an ajax request is made, but I can't see the errors that the visitor gets when trying to fill out a form.
Share this topic:
Page 1 of 1

Help














