看看這個代碼:CakePHP的2.0檢測請求類型是奇怪行爲
if ($this->request->is('post')){
$this->request->data['Profile']['userId'] = $this->Auth->user('id');
if ($this->Profile->save($this->request->data)){
$this->Profile->setPermissions($this->Profile->id, $this->request->data['Permission']);
$this->NFSSession->setSuccessMessage('Your profile has been updated.');
}else{
$this->NFSSession->setSuccessMessage('There was a problem updating your profile. Please try again.');
}
}else{
echo 'Not a post request!!?!?!?!?!';
debug($this->request->data);
}
當我在此動作對應的視圖提交表單,看來這 - $>請求 - >是( 'post')返回false。運行if/else語句的另一端。這裏的怪異位 - POST數據是存在的,而且我調試調用($這個 - >請求 - >數據)吐出我期待中的數據!
下面是被傳遞的數據:
Array
(
[Profile] => Array
(
[aboutMe] => Hey there
)
[Permission] => Array
(
[Profile] => Array
(
[aboutMe] => 1
)
)
)
現在,我當然可以只改變$這個 - >請求 - >是(「後」)空($這個 - >請求 - >數據),但這並不能解決問題。
那麼什麼是錯我的代碼?這是怎麼回事?
謝謝!
確實你的觀點是什麼樣子?特別是你提交的表單。 – Oldskool
它產生上述的POST數據 - 當然這是對美景的相關信息(道歉,如果我想的東西)? – Will