ユーザーがアカウントの詳細を編集できるようにしようとしていますが、次のエラーが発生しました。(ケーキ初心者です...)
エラーは「致命的なエラー: 行 79 の /home/www/7b8dad242e3d067ccc5448180944bdab/web/shop/Controller/UsersController.php の非オブジェクトに対するメンバー関数 user() の呼び出し」です。
ビュー: (edit.ctp)
<?php echo $this->Form->create('User');?>
<fieldset>
<legend><?php echo __('Edit Details'); ?></legend>
<?php
echo $this->Form->input('id');
echo $this->Form->input('name');
echo $this->Form->input('surname');
echo $this->Form->input('email');
echo $this->Form->input('password');
echo $this->Form->input('street');
echo $this->Form->input('number');
echo $this->Form->input('zipcode');
echo $this->Form->input('city');
echo $this->Form->input('country');
echo $this->Form->input('tel');
?>
</fieldset>
<?php echo $this->Form->end(__('Submit'));?>
* CONTROLLER (UsersController.php) * 79行目はコードの2行目
public function edit($id = null) {
if($this->Auth->user() && $this->Auth->user('id') == $id) {
$this->User->read(null, $id);
$this->User->set(array(
'name' => $this->data['User']['name'],
'surname' => $this->data['User']['surname'],
'email' => $this->data['User']['email'],
'street' => $this->data['User']['street'],
'number' => $this->data['User']['number'],
'city' => $this->data['User']['city'],
'zipcode' => $this->data['User']['zipcode'],
'country' => $this->data['User']['country'],
'tel' => $this->data['User']['tel'],
));
$this->User->save();
}
}
* auth method
*
* @return void
*/
public function auth() {
$auth = $this->User->find('first', array(
'conditions' => array('User.email' => $this->request->data['email'], 'User.password' => $this->request->data['password'])));
if($auth == null) {
$this->Session->setFlash('Incorrect user or password', 'default', array(), 'auth');
$this->redirect(array('action' => 'add'));
} else {
$this->Session->write('logged_user', $this->request->data['email']);
//debug($_SESSION['logged_user']);
$this->redirect(array('controller' => 'products', 'action' => 'index'));
}
}
/**
どんな提案でも大歓迎です。どうもありがとう