Saturday, April 20, 2013

Yii model without table

<?php
class RegistrationForm extends CFormModel
{
    public $email;
    public $password;
    public $repassword;
    public $displayname;
    public $verifycode;


    public function rules()
    {
        return array(
            array('email, password, repassword', 'required'),
            array('password, repassword', 'length', 'min'=>4),
            array('email, password, repassword, displayname', 'length', 'max'=>200),
            array('email', 'unique'),
            array('repassword', 'compare', 'compareAttribute'=>'password'),
            array('email', 'email'),
            array('verifycode', 'captcha', 'allowEmpty'=>!CCaptcha::checkRequirements()),
        );
    }
    
    
    public function attributeLabels()
    {
        return array(
            'email'=>'Email',
            'password'=>'Password',
            'repassword'=>'Re-Password',
            'displayname'=>'Display Name',
            'verifycode'=>'Confirm you are not alien',
        );
    }
           
}

No comments:

Post a Comment