Apparently, when it's a put!
I've been struggling for a couple of hours to work out why my unit test for
an edit action is working wonderfully, but it's not working via the browser.
The URL is /users/edit/75, where 75 is the id of the user I'm editing.
So, my unit test has $this->testAction('/users/edit/75', array('data' =>
$data, 'method' => 'post'))
In my edit action, I do a if ($this->request->is('post')) to test if the
form has been submitted, and process accordingly.
In my view, I have echo $this->Form->create(null, array('id' =>
'edituser')); to generate the form element. The generated element is <form
action="/synapse/users/edit/78?pnumis=" id="edituser" method="post"
accept-charset="utf-8">
After sticking a bunch of debugging through the code, I finally figure out
that the condition is failing, because from the browser,
$this->request->method() == 'PUT'!, even though the submit is actually a
POST (from Chrome Network).
It occurs to me that this is happening because I'm targeting a specific
user to edit, and the typical REST action is a PUT, rather than POST (which
would be used for a create).
I'm going to do a little tracking down in the code to see if I can work out
where/why this is happening, but anyone happens to have had experience with
this, and what I should be doing instead, please let me know.
Regards
Reuben Helms
--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP
---
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.