Difference between #1 and #2 of
Custom Login Error Messages

Revision #2 has been created by whoopass on Mar 5, 2013, 6:45:32 PM with the memo:

Added image of custom error example.
« previous (#1)


Title unchanged

Custom Login Error Messages

Category unchanged


Yii version unchanged

Tags unchanged

custom error, login, LoginForm, UserIdentity, error message, errorCode, addError

Content changed

$this->addError('username', 'Username is currently not active, please activate using the activation URL in your email and try again.');

The final result is:
![Custom Error](http://www.sterlingsavvy.com/tutorials/uploads/login_error_customization/custom_error.PNG "Custom Error")
One final thing to note is that the addError pulls an attribute value first, here you see 'username' or 'password'. These reference to which field to show the error under. In our case with our custom value we know the user authenticates properly and exist in our DB, they just haven't activated their account yet. As such we label the error to the 'username'.

That's it for the tutorial, I hope you learned a lot in understanding how to follow the logical flow of code assignments and debugging the functions, variables and classes in this case. I also hope this helps you put to good use how to modify your own custom errors into the login authentication process.

Thanks for reading!
~ Whoopass
6 0
Viewed: 40 820 times
Version: 1.1
Category: Tutorials
Written by: whoopass
Last updated by: whoopass
Created on: Mar 5, 2013
Last updated: 5 years ago
Update Article


View all history