在模型BaseUser.php中,我定义了$verifyPassword
并将其添加到规则中
public function rules() {
return array(
array('name, email, phone_code, phone, country, language, password, role, status', 'required'),
array('verifyPassword','required', 'on'=>'insert'),
array('country, role, status, payment', 'numerical', 'integerOnly'=>true),
array('name, email, active_key', 'length', 'max'=>50),
array('phone_code', 'length', 'max'=>5),
array('phone', 'length', 'max'=>30),
array('language', 'length', 'max'=>10),
array('password', 'length', 'max'=>32),
array('verifyPassword', 'length', 'max'=>32),
array('device_token, token', 'length', 'max'=>100),
array('created', 'safe'),
array('country', 'haveToSelect'),
array('email', 'unique', 'message' => Yii::t('app',"This user's email adress already exists.")),
array('verifyPassword', 'compare', 'compareAttribute'=>'password'),
array('device_token, active_key, token, payment, created', 'default', 'setOnEmpty' => true, 'value' => null),
array('id, name, email, phone_code, phone, country, language, password, role, device_token, active_key, status, token, payment, created', 'safe', 'on'=>'search'),
);
}
在配置文件控制器中.php
public function actionIndex()
{
$data = Yii::app()->session['Authentication'];
$idUserLogin = $data->id;
$dataUser = Users::model()->findByPk($idUserLogin);
if (isset($_POST['Users'])) {
$dataUser->setAttributes($_POST['Users']);
if($dataUser->save()) {
Yii::app()->user->setFlash('success',Yii::t('app','Change profile successful!'));
$this->refresh();
}
}
我成功注册了一个新帐户,但在另一个使用配置文件的用户功能中...更改后我无法保存。
例如,在功能中,按保存按钮时更改配置文件...什么都没有改变...没什么警报...没有验证通知。
如何解决这个问题?
我喜欢这个问题...
我更改了规则:
public function rules() {
return array(
array('name, email, phone_code, phone, country, language, password, role, status', 'required'),
array('verifyPassword','required', 'on'=>'register'),
array('country, role, status, payment', 'numerical', 'integerOnly'=>true),
array('name, email, active_key', 'length', 'max'=>50),
array('phone_code', 'length', 'max'=>5),
array('checkAgree', 'required', 'requiredValue' => 1, 'message' => 'You must have to agree with...', 'on'=>'register'),
array('phone', 'length', 'max'=>30),
array('language', 'length', 'max'=>10),
array('password', 'length', 'max'=>32),
array('verifyPassword', 'length', 'max'=>32),
array('device_token, token', 'length', 'max'=>100),
array('created', 'safe'),
array('country', 'haveToSelect'),
array('email', 'unique', 'message' => Yii::t('app',"This user's email adress already exists.")),
array('verifyPassword', 'compare', 'compareAttribute'=>'password', 'on'=>'register'),
array('device_token, active_key, token, payment, created', 'default', 'setOnEmpty' => true, 'value' => null),
array('id, name, email, phone_code, phone, country, language, password, role, device_token, active_key, status, token, payment, created', 'safe', 'on'=>'search'),
);
}
我在注册场景中检查"验证密码"
在我的控制器中,我定义了:
$user = new User('register')