help with CFormModel

Hello, I want to create a registration script and first of all I have created RegisterForm.php and after it I wanted to generate a form from Gii but Gii just shows me a blank page, nothing on it. so I thought that something should be wrong in RegisterForm.php <-model. here is a code:


class RegisterForm extends CFormModel


	public $username;

	public $password;

	public $password2;

	public $email;

	public $fullname;

	public $birth;


	public function rules()


        return array(

            array('username, password, password2, email, fullname, birth', 'required'),




			array('username', 'filter', 'filter'=>'strtolower')

			array('username', 'ext.alpha', 'allowSpaces'=>'flase', 'allAccentedLetters'=>'false', 'allowEmpty' => 'false'),

			array('username', 'unique', 'attributeName'=> 'username', 'caseSensitive' => 'false'),


			array('password', 'length', 'min' =>6),

			array('password', 'length', 'max' =>32),

			array('password', 'compare', 'allowEmpty' => 'false', 'compareAttribute' => 'password2', 'strict' => 'true'),


			array('email', 'length', 'min' =><img src='' class='bbc_emoticon' alt='8)' />,

			array('email', 'length', 'max' =>128),

			array('email', 'email'),




			array('fullname', 'ext.alpha', 'allowNumbers'=>'false', 'allAccentedLetters'=>'false'),


			array('birth', 'date', 'allowEmpty'=>'false', 'format'=>'dd/MM/yyyy'),




So you created a model - good.

Are you trying to create CRUD for that model and getting a blank page in gii?

Thank you for reply. My problem is that I have an error in these rules and this is the problem:

array('username', 'unique', 'attributeName'=> 'username', 'caseSensitive' => 'false'),

it shows this error:

RegisterForm and its behaviors do not have a method or closure named "tableName".

can you help me? please?

Unique but compared to what? Your model class extends CFormModel. It means that the model is not associated with a database table, so CUniqueValidator doesn’t know where to look for the “username” column.

so, What you advice?

Problem is solved!!!!!

A guy, named "DCoder", from gave me a solution, that was really simple:

Changed code:

array('username', 'unique', 'attributeName'=> 'username', 'className'=>'User','caseSensitive' => 'false'), 

User is a User.php, the Model that was generated from Gii.

I tried it, but it doesn’t work for me.I use Yii 1.1.10.


public function rules()


		// NOTE: you should only define rules for those attributes that

		// will receive user inputs.

		return array(

			array('tenDangNhap, matKhau, email', 'required'),

                        array('matKhau2', 'required'),

                        array('matKhau2', 'compare','compareAttribute'=>'matKhau'),

                        array('tenDangNhap','unique','attributeName'=>'tenDangNhap', 'className'=>'TaiKhoan', 'caseSensitive' => 'false'),

			array('email', 'email'),

                        array('email', 'unique', 'attributeName'=> 'email', 'className'=>'NguoiDunq','caseSensitive' => 'false'),

			array('tenDangNhap', 'length', 'max'=>30,'min'=>6),

			array('matKhau', 'length', 'max'=>20),

			// The following rule is used by search().

			// Please remove those attributes that should not be searched.

			array('maTaiKhoan, tenDangNhap, email', 'safe', 'on'=>'search'),




<div class="form">

<?php $form=$this->beginWidget('CActiveForm', array(








)); ?>

	<?php echo $form->errorSummary($model); ?>

	<div class="row">

		<?php echo $form->labelEx($model,'tenDangNhap'); ?>

		<?php echo $form->textField($model,'tenDangNhap'); ?>

		<?php echo $form->error($model,'tenDangNhap'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'matKhau'); ?>

		<?php echo $form->passwordField($model,'matKhau'); ?>

		<?php echo $form->error($model,'matKhau'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'matKhau2'); ?>

		<?php echo $form->passwordField($model,'matKhau2'); ?>

		<?php echo $form->error($model,'matKhau2'); ?>


	<div class="row">

		<?php echo $form->labelEx($model,'email'); ?>

		<?php echo $form->textField($model,'email'); ?>

		<?php echo $form->error($model,'email'); ?>



	<div class="row buttons">

		<?php echo CHtml::submitButton('Submit'); ?>


<?php $this->endWidget(); ?>

</div><!-- form -->

What wrong in my code?