Wednesday, October 24, 2012

Re: request says put instead of post

Just wasted 20 minutes on this and figured I'd post a solution for those that google this problem.

It seems that this is a Cake "feature" that won't be fixed (even though it creates more work than v1.3):
http://cakephp.lighthouseapp.com/projects/42648/tickets/2528-request-type-put-instead-of-post

So either use Mark's workaround from the above link, or what I did was change my "create" call to force POST:
$this->Form->create('Blah', array('type' => 'post'));




On Thursday, December 8, 2011 5:08:58 PM UTC-5, euromark wrote:
scratch that - recordExists is true, therefore created is true and the
action is not submitted in the options array (which is optional after
all!).
but that should not result in a put afaik.
at least not if the documentation states that we should check with the
above if statement

I would expect POST to be set if PUT is set (as PUT is usually a sub-
part of POST). or ALWAYS set POST.

On 8 Dez., 23:03, euromark <dereurom...@googlemail.com> wrote:
> I think its the FormHelper
>
> a simple:
> <?php echo $this->Form->create('User', array('id'=>'userData'));?>
>
> results in:
> <form action="/admin/members/edit/
> 4edeb06d-7080-4e23-8438-0fe01810f9bf" id="UserAdminEditForm"
> method="post" accept-charset="utf-8"><div style="display:none;"><input
> type="hidden" name="_method" value="PUT"/></div>...
>
> so obviously it thinks this is a non-existing record
> //FormHelper.php
> 'type' => ($created && empty($options['action'])) ? 'put' : 'post',
>
> $created is true and $options['action'] is undefined => put...
>
> On 8 Dez., 22:47, Miles J <mileswjohn...@gmail.com> wrote:
>
>
>
>
>
>
>
> > What are your HTTP headers?
>
> > On Dec 8, 1:44 pm, euromark <dereurom...@googlemail.com> wrote:
>
> > > thats really weird.
> > > happening on windows/wamp - php5.3.8
> > > maybe some bug?
>
> > > the firefox firebug debug data for POST reads:
>
> > > Parameter application/x-www-form-urlencoded
> > > _method PUT
> > > data[UserInfo][country_id...    1
> > > data[UserInfo][gender]  1
> > > data[User][id]  4ed23d7c-dcc8-4d3b-8e7b-0fe01810f9bf
> > > data[User][username]    test
>
> > > so it seems to put everything by default.
> > > As far as I know, POST is more generic and PUT mainly used for upload
> > > etc
>
> > > On 8 Dez., 21:04, Tilen Majerle <tilen.maje...@gmail.com> wrote:
>
> > > > i was checking this what you said that didn't work and results
> > > > checking: $this->request->is('post')
>
> > > > in Google Chrome (latest): true
> > > > Firefox (latest): true
> > > > IE 8: true
>
> > > > i'm on xampp 1.7.3 with php 5.3.5
> > > > and Cake version: 2.0.4
>
> > > > so problem is somewhere in your project or maybe server configuration
> > > > --
> > > > Lep pozdrav, Tilen Majerlehttp://majerle.eu
>
> > > > 2011/12/8 euromark <dereurom...@googlemail.com>
>
> > > > > For 2.0 I just changed all
> > > > > if (!empty($this->data))
> > > > > to
> > > > > if ($this->request->is('post'))
>
> > > > > But now it haunts be.
> > > > > In FF8 Cakephp $this->request does say "false" after a normal post
> > > > > (whereas firebug itself says it is a post)
> > > > > but is('put') returns true
> > > > > Same with every other browser it seems.
>
> > > > > so it never saves...
> > > > > whats going on?
>
> > > > > --
> > > > > Our newest site for the community: CakePHP Video Tutorials
> > > > >http://tv.cakephp.org
> > > > > Check out the new CakePHP Questions sitehttp://ask.cakephp.organdhelp
> > > > > others with their CakePHP related questions.
>
> > > > > To unsubscribe from this group, send email to
> > > > > cake-php+u...@googlegroups.com For more options, visit this group
> > > > > athttp://groups.google.com/group/cake-php

--
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 post to this group, send email to cake-php@googlegroups.com.
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php?hl=en.
 
 

No comments: