0
CakePHP 2、私は編集ページを持っています。私は何が変わったのか見たいと思います。したがって、私は$ this-> request-> dataを取得する必要があります。ただし、古いレコード(非編集)と新しいレコード(編集済み)を取得できません。どうしたらいいですか?変更されたデータは、ます$ this->要求 - >データで見ることができ、あなたがポストされたデータを保存する前に、データベースから古いデータを読み取ることができcakephp編集ページで古いレコードと新しいレコードを取得する
public function admin_edit($id = null) {
$this->BrandImage->id = $id;
if (!$this->BrandImage->exists($id)) {
throw new NotFoundException(__('Invalid brand image'));
}
$old_content = array();
$new_content = array();
***debug($this->request->data);***
if ($this->request->is('post') || $this->request->is('put')) {
if ($this->BrandImage->save($this->request->data)) {
***debug($this->request->data);***
$this->Session->setFlash(__('The brand image has been saved'), 'flash/success');
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The brand image could not be saved. Please, try again.'), 'flash/error');
}
} else {
$options = array('conditions' => array('BrandImage.' . $this->BrandImage->primaryKey => $id));
$this->request->data = $this->BrandImage->find('first', $options);
}
$brands = $this->BrandImage->Brand->find('list');
$imageTypes = $this->BrandImage->ImageType->find('list');
$this->set(compact('brands', 'imageTypes'));
}