Ваш edit.ctp:
<?php
echo $form->create('Login');
echo $form->input('id');
echo $form->input('first_name');
echo $form->input('last_name');
echo $form->input('email');
echo $form->input('user_name');
echo $form->input('password');
echo $form->input('Userdetail.id');//updated
echo $form->input('Userdetail.first_name');
echo $form->input('Userdetail.last_name');
echo $form->input('Userdetail.designation');
echo $form->input('Userdetail.contact');
echo $form->input('Userdetail.address');
echo $form->end('Submit');
?>
Ваше действие редактирования в контроллере:
function edit($id = null)
{
$this->set('title_for_layout', __('Edit', true));
if (!$id && empty($this->data)) {
$this->Session->setFlash(__('Invalid ', true), 'default', array('class' => 'error'));
$this->redirect(array('action'=>'index'));
}
if (!empty($this->data)) {
if ($this->Login->save($this->data)) {
$this->Userdetail->create();//updated code
$this->Userdetail->id = $this->data['Userdetail']['id'];//updated code
if ($this->Userdetail->save($this->data['Userdetail'])) {
$this->Session->setFlash(__('Data has been saved', true), 'default', array('class' => 'success'));
$this->redirect(array('action'=>'index'));
}
} else {
$this->Session->setFlash(__('Data could not be saved. Please, try again.', true), 'default', array('class' => 'error'));
}
}
if (empty($this->data)) {
$this->data = $this->Login->read(null, $id);
}
}