アプリで Venue モデルのレコードを編集するためのページがあります。このページは、ある段階では機能していましたが、現在は機能していません。
コントローラ アクションで $this->data をデバッグすると、期待されるフォーム値の配列が得られます。ただし、Venue モデルでは、beforeSave で $this->data をデバッグすると、関連する (HABTM) モデル、カテゴリのフィールドの値のみが得られます。
app/models/venue.php (line 89)
Array
(
[Category] => Array
(
[Category] => Array
(
[0] => 1
[1] => 2
[2] => 8
)
)
)
フォームがコントローラー アクションに送信されてから beforeSave が呼び出されるまでの間に、このデータに何が起こっているのでしょうか? これをデバッグするにはどこを見ればいいですか?
ありがとう
編集 - コントローラーの $this->data の内容は次のとおりです (実際のデータは、電話番号や住所などを削除するために変更されています)。
app/controllers/venues_controller.php (line 63)
Array
(
[Venue] => Array
(
[id] => 19
[city_id] => 1
[user_id] => 130
[name] => Acme Zoo
[email] => events@acmezoo.org.uk
[description] =>
Some text...
[blurb] => Truncated description...
[contact_id] =>
[address_1] => Acme Zoo
[address_2] => Some Road
[postcode] => PP9 4DD
[telephone] => 010101010101
[website] =>
[latitude] => 55.21222
[longtitude] => -2.111111
[featured] => 0
[active] => 1
[flagged] => 0
[smg] => 0
[smg_custom_icon] => 1
[listings] => 1
[send_email] => 0
[file] => Array
(
[name] =>
[type] =>
[tmp_name] =>
[error] => 4
[size] => 0
)
)
[Category] => Array
(
[Category] => Array
(
[0] => 3
[1] => 6
[2] => 10
)
)
)
そして、これがデータを保存するための私のコードです...
if (!empty($this->data)) {
if ($this->Venue->save($this->data)) {
$this->Session->setFlash('The venue has been saved','success');
$countryId = $this->Venue->City->field('country_id',array('id'=>$this->data['Venue']['city_id']));
if (!empty($this->data['Venue']['send_email'])){
$this->_emailVenue($this->Venue->id,'venue_added',$countryId);
}
$this->redirect(array('action' => 'index','city'=>$this->data['Venue']['city_id']));
} else {
$this->Session->setFlash('The venue could not be saved. Please, try again.','failure');
}
}