我有我的應用程序的場館模型的編輯記錄的頁面消失。該頁面正在某個階段工作,但現在已經斷開。
在控制器動作,調試$這 - >數據形式給出的值的預期陣列。然而,在場館模型,在beforeSave調試$這個 - >數據來自相關(HABTM)模型給出僅對字段的值,類別:
app/models/venue.php (line 89)
Array
(
[Category] => Array
(
[Category] => Array
(
[0] => 1
[1] => 2
[2] => 8
)
)
)
什麼可以發生在表單之間的數據提交到控制器的動作,並調用beforeSave?我應該在哪裏調試呢?
感謝
編輯 - 這裏是什麼在$這個 - >數據控制器(實際數據改爲刪除電話號碼,地址等)。
app/controllers/venues_controller.php (line 63)
Array
(
[Venue] => Array
(
[id] => 19
[city_id] => 1
[user_id] => 130
[name] => Acme Zoo
[email] => [email protected]
[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');
}
}
是否可以發佈您的控制器的$ this->數據?我不喜歡['Category'] ['Category']的外觀! – Leo
顯示save()的代碼 –
我已經添加了這些位,謝謝。據我所知,['Category'] ['Category']是Cake如何處理HABTM關聯?在視圖中,我只是使用$ form-> input('Category'); – Will