我有一個CakePHP的2.1驗證規則模型驗證規則和功能
'name' => array(
'empty' => array(
'rule' => 'notEmpty',
'required' => true,
'allowEmpty' => false,
'message' => 'Name is required.'
),
'unique' => array(
'rule' => 'checkUnique',
'required' => true,
'allowEmpty' => false,
'message' => 'Name already exists.'
)
)
我爲TE checkUnique方法如下代碼:
public function checkUnique($data)
{
//App::import('Model','User');
// $this->User = & new User();
if(empty($this->data['TeacherLocation']['id']))
{
$locationInfo = $this->find
(
'all',
array
(
'conditions'=>array
(
'user_id' => $this->data['TeacherLocation']['user_id'],
'name' => $this->data['TeacherLocation']['name']
),
'recursive' => -1
)
);
return (empty($locationInfo));
但我不斷收到關於無法一個錯誤找到索引user_id。是什麼賦予了?