M使用蛋糕2.6.0 我的模型user.php 在用户模型中,它给出了
错误:未定义的索引:group_id [APP \ Model \ User.php]
public function bindNode($user) {
return array('model' => 'Group', 'foreign_key' => $user['User']['group_id']);
}
public $hasAndBelongsToMany = array(
'Group' => array(
'className' => 'Group',
'joinTable' => 'groups_users',
'foreignKey' => 'user_id',
'associationForeignKey' => 'group_id',
'unique' => 'keepExisting',
'conditions' => '',
'fields' => '',
'order' => '',
'limit' => '',
'offset' => '',
'finderQuery' => '',
)
);
login.ctp
echo $this->Form->create('User', array(
'url' => array(
'controller' => 'users',
'action' => 'login'
)
));
echo $this->Form->input('User.username');
echo $this->Form->input('User.password');
echo $this->Form->input('User.group_id', array('type' => 'select', 'empty' => '---Select Role---'));
echo $this->Form->end('Login');
我想在bindNode()函数中获取user.group_id,该函数在登录时选择。