Reputation: 99
I have to edit a form where it contains datas form two tables. one is master and another user. first the data is saved in user table and with that id the remaining datas get saved in master table. Below is my edit code.What should i do to fetch the data and edit it.
public function edit() {
$id = $this->request->params['pass'][0];
$this->Master->id = $id;
if( $this->Master->exists()){
if( $this->request->is( 'post' ) || $this->request->is( 'put' ) ){
if( $this->Master->save( $this->request->data ) ){
$this->redirect(array('action' => 'index'));
}
else {
$this->Session->setFlash('Unable to edit row. Please, try again');
}
}
else {
$this->request->data = $this->Master->read();
}
}
}
Could somebody help pls..
Upvotes: 0
Views: 96
Reputation: 1120
Update your code by :
$this->request->data = $this->Master->read(null, $id);
$this->set('masterArr',$this->Master->find('all',array('conditions' =>
array('Master.id ' => $id))));
Upvotes: 1