【发布时间】:2012-02-26 15:29:07
【问题描述】:
我在 Yii 框架中有这么一小行代码:
array('username', 'unique', 'attributeName'=> 'username', 'caseSensitive' => 'false'),
这给了我一个错误:
RegisterForm and its behaviors do not have a method or closure named "tableName".
完整的 RegisterForm.php 模型:
<?php
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','length','min'=>3),
array('username','length','max'=>16),
array('username', 'filter', 'filter'=>'strtolower'),
array('username', 'ext.alpha', 'allowSpaces'=>'flase', 'allAccentedLetters'=>'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' =>8),
array('email', 'length', 'max' =>128),
array('email', 'email'),
array('fullname','length','min'=>6),
array('fullname','length','max'=>64),
array('fullname', 'ext.alpha', 'allowNumbers'=>'false', 'allAccentedLetters'=>'false'),
array('birth', 'date', 'allowEmpty'=>'false', 'format'=>'dd/MM/yyyy'),
);
}
}
【问题讨论】:
-
您的问题是什么?我猜你需要在某个地方告诉 Yii 寻找独特性。
-
您能准确告诉我必须添加或更改的内容吗?
-
不,我不能,但我确信这在 Yii 网站上有记录。
-
感谢您给我无用的、类似猜测的答案
标签: php forms frameworks yii validation