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 to the appropriate view for this action, it seems that $ this-> request-> is ('post') returns false. The other end of the if / else statement is executed. Here's a weird bit - there is POST data, and my debug call ($ this-> request-> data) spits out the data I expect!
The data is transferred here:
Array ( [Profile] => Array ( [aboutMe] => Hey there ) [Permission] => Array ( [Profile] => Array ( [aboutMe] => 1 ) ) )
Now I could just change $ this-> request-> is ('post') to! empty ($ this-> request-> data), but this will not affect the problem.
And is there something wrong with my code? What's happening?
Thanks!
source share