Take a look at this code:
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);
}
When I submit the form in the corresponding view for this action, it appears that $this->request->is('post') returns false. The other end of the if/else statement is run. Here's the weird bit - the POST data is there, and my call to debug($this->request->data) spits out the data I am expecting!
Here's the data that gets passed:
Array
(
[Profile] => Array
(
[aboutMe] => Hey there
)
[Permission] => Array
(
[Profile] => Array
(
[aboutMe] => 1
)
)
)
Now, I could of course just change $this->request->is('post') to !empty($this->request->data) but that would not be grappling the problem head on.
So is anything wrong with my code? What's going on?
Thanks!
Try using this:
if ($this->request->is('post') || $this->request->is('put'))
http://cakephp.lighthouseapp.com/projects/42648/tickets/2353
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With