小编Dee*_*mas的帖子

Yii验证特定字段

问题捍卫

我有一个名为'user.php'的模型我有相同的验证规则如下我现在要创建一个密码重置表单在该表单我有一个文本框名称电子邮件(用户模型中使用相同的电子邮件)密码重置表单我想检查这个用户是否已注册,如果注册的用户将发送密码重置链接

我不知道如何撤销这个电子邮件领域,任何帮助都非常令人满意,因为我在YII中是新的

user.php的

    class Users extends CActiveRecord
{
public $cpassword;
    public static function model($className=__CLASS__)
    {
        return parent::model($className);
    }
public function tableName()
    {
        return 'users';
    }
public function rules()
    {
        // NOTE: you should only define rules for those attributes that
        // will receive user inputs.
        return array(
            array('email, password, user_type , cpassword','required'),
            array('email', 'length', 'max'=>200),
                        array('email', 'unique'),
                        array('email', 'email'),
            array('password', 'length', 'max'=>300),
                        array('cpassword', 'length', 'max'=>300),
            array('user_type', 'length', 'max'=>5),
                        array('cpassword', 'compare', 'compareAttribute' => 'password'),

            // The following rule is used …
Run Code Online (Sandbox Code Playgroud)

php yii

2
推荐指数
1
解决办法
1万
查看次数

标签 统计

php ×1

yii ×1