Questions about the Yii framework form validation. The great God who understands yii please come in and have a look ... 
I am using Yii to do a simple small blog, in the background when the login verification, there are bugs, 
Do not prompt login error message, I do is account, password, verification code can not be empty. 
And it does not match the database. I have tested that the database connection is completely fine. 
 
logincontroller.php 
 /** 
* Backstage Login Controller 
*/ 
Class Logincontroller extends controller{ 
/** 
* Background Login Template 
*/ 
Public Function Actionindex () { 
$loginForm = new LoginForm (); 
if (Isset ($_post[' $LoginForm ')) { 
$loginForm->attributes = $_post[' loginform '); 
if ($loginForm->validate ()) { 
Echo 1;die; 
} 
} 
$this->render (' index ', array (' loginform ' = $loginForm)); 
} 
 
Public function actions () { 
Return Array ( 
' Captcha ' = Array ( 
' Class ' = ' system.web.widgets.captcha.CCaptchaAction ', 
' Height ' = 25, 
' Width ' = 80, 
' MinLength ' = 4, 
' MaxLength ' = 4, 
' Offset ' = 3, 
' Padding ' = 1 
), 
); 
} 
} 
 
This is model,user.php. 
 /** 
* Background User model 
*/ 
Class User extends cactiverecord{ 
/** 
* Must be indispensable method one, return to the model 
*/ 
public static function model ($className = __class__) { 
Return Parent::model ($className); 
} 
 
/** 
* Must not be the method two, return the table name 
*/ 
Public Function TableName () { 
Return "{{user}}"; 
} 
} 
 
This is one of the ways in loginform.php. 
Public Function Rules () 
{ 
Return Array ( 
Username and password are required 
Array (' username ', ' required ', ' message ' = ' user name cannot be null '), 
Array (' password ', ' Required ', ' message ' = ' password cannot be null '), 
RememberMe needs to bes a Boolean 
Array (' RememberMe ', ' Boolean '), 
Password needs to be authenticated 
Array (' Password ', ' Authenticate '), 
Custom error messages 
Array (' Captcha ', ' captcha ', ' message ' = ' Verification Code error '), 
); 
} 
 
This is the page that outputs the error message index.php 
 
 
  
  
 
  -  Error ($loginForm, ' username ')?>
 
 
 
  
  
 
  -  Error ($loginForm, ' password ')?>
 
 
 
  
  
 
  -  Error ($loginForm, ' captcha ')?>
 
 
This is the useridentity.php in the components directory. 
  
/** 
* Useridentity represents the data needed to identity a user. 
* It contains the authentication method that checks if the provided 
* Data can identity the user. 
*/ 
Class Useridentity extends Cuseridentity 
{ 
/** 
* Authenticates a user. 
* The example implementation makes sure if the username and password 
* is both ' demo '. 
* In practical applications, this should is changed to authenticate 
* Against some persistent user identity storage (e.g. database). 
* @return Boolean whether authentication succeeds. 
*/ 
Public function Authenticate () 
{ 
$userInfo = User::model ()->find (' username =: Name ', Array (': name ' = = $this->username)); 
if ($userInfo = = NULL) { 
$this->errorcode = self::error_username_invalid; 
return false; 
} 
if ($userInfo->password!== MD5 ($this->password)) { 
$this->errorcode = self::error_password_invalid; 
return false; 
} 
$this->errorcode = Self::error_none; 
return true; 
} 
} 
 
 
What went wrong, the database link has been measured, no problem at all. 
Now, even if the error message is written, it is not prompted and does not perform login verification. In addition to the verification code can be replaced, completely like a static page. 
------Solution-------------------- 
if (Isset ($_post[' $LoginForm '))) {??? 
Yes if (isset ($_post[' loginform ')) {bar