It looks to be somewhat of a mess, but the bug is not in
RequestHandler itself.

When you create the form, if you don't specify it, FormHelper->create
assigns the method POST or PUT to the form depending on whether the
record already exists or not. So when there is a record (edit), the
verb is PUT and not POST. One problem is that this verb is assigned to
a hidden field in the form and cake uses the verb from there across
the board on post back. So when submitted, isPost will not work but
isPut will. I have no idea why a special hidden field is used instead
of the HTTP verb itself, maybe there is good reason for that but it's
very confusing.

This is also contrary to the [arguable] consensus on mapping CRUD to
HTTP verbs:

* Create = PUT
* Retrieve = GET
* Update = POST
* Delete = DELETE

The above is arguable, some say that PUT and POST can be both used for
Create and Update depending on some more subtle differences I will not
get into here.

- barduck

On Mar 10, 8:01 pm, Miles J <[email protected]> wrote:
> The main problem I always would run into would that it would not
> recognized a POST, so the form would do nothing. I would usually have
> to submit it twice before it worked.
>
> Never figured out why it did that.
>
> On Mar 10, 7:03 am, Jimmy Bourassa <[email protected]> wrote:
>
> > Thanks Miles,
>
> > Can you be a bit more specific regarding the bugs you've seen?
>
> > Thanks,
>
> > On 10 mar, 00:17, Miles J <[email protected]> wrote:
>
> > > Yes exactly. RequestHandler would force it only if the HTTP method is
> > > POST, where as $data would work no matter what source it came from. I
> > > prefer RequestHandler, but it has been buggy sometimes.
>
> > > On Mar 9, 6:10 pm, Jimmy Bourassa <[email protected]> wrote:
>
> > > > Hello,
>
> > > > I realized that everyone seems to do an empty() call on $this->data in
> > > > controllers in order to check if data has been posted or not.
>
> > > > Is it just me or RequestHandler::isPostyields better results? This
> > > > would allow to pre-fill Controller::$data in various situations.
>
> > > > Thanks,
>
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

To unsubscribe from this group, send email to 
cake-php+unsubscribegooglegroups.com or reply to this email with the words 
"REMOVE ME" as the subject.

Reply via email to