0

M 使用 cake 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' => '',
        )
    );

登录.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,该函数在登录时选择。

4

0 回答 0