this is my controller's edit_profile function:
public function editProfile()
{
$user = $this->UserAuth->getUser();
$userId = $user['User']['id'];
$this->loadModel('Restaurant');
$_restaurants = $this->Restaurant->find('list');
$this->set('restaurants', $_restaurants);
if (!empty($userId)) {
$userGroups = $this->UserGroup->getGroups();
$this->set('userGroups', $userGroups);
if ($this->request->isPut()) {
$this->request->data['User']['restaurant_name'] = trim($_restaurants[$this->request->data['User']['restaurantid']]);
$this->User->set($this->data);
if ($this->User->RegisterValidate()) {
if (empty($this->request->data['User']['password'])) {
unset($this->request->data['User']['password']);
} else {
$this->request->data['User']['password'] = $this->UserAuth->makePassword($this->request->data['User']['password']);
}
$this->User->create();
$this->User->save($this->request->data, false);
$this->Session->setFlash(__('The user is successfully updated'));
$this->redirect(array ('plugin' => false, 'controller' => 'orders', 'action' => 'orderList'));
}
} else {
$user = $this->User->read(null, $userId);
$this->request->data = null;
if (!empty($user)) {
$user['User']['password'] = '';
$this->request->data = $user;
}
}
} else {
$this->redirect(array ('plugin' => false, 'controller' => 'orders', 'action' => 'orderList'));
}
}
my problem is browser says, there is undefined index: restaurantid, in this line
$this->request->data['User']['restaurant_name'] = trim($_restaurants[$this->request->data['User']['restaurantid']]);
but i load my restaurant model, somebody help me to solve this problem.