$form->create, and the request method

227 views
Skip to first unread message

francky06l

unread,
Nov 4, 2007, 12:58:36 PM11/4/07
to CakePHP Bleeding Edge
Hi All,

Using the latest 1.2 from the branch I noticed something that can
sometimes trouble an existing application.

When you create a form such as :

$form->create(array('controller' => 'Users', 'action' => 'edit')), the
call to isPost (requestHandler) will return true.

Now doing :

$form->create(array('url' => '/users/edit')), the same call to the
requestHandler isPost will return false, but the isPut will return
true.

You can style pass 'style' => 'post' with the second method and that
will be seen as a "post".

This is coming from the form helper, which set the method as "put"
when no 'action' option is set in the parameter array.

I do not know if component such as "Security" and the require Post is
handling this correctly. Actually no a big deal, but that can make you
searching for a while.

Felix Geisendörfer

unread,
Nov 4, 2007, 1:45:40 PM11/4/07
to cakeph...@googlegroups.com

$form->create(array('controller' => 'Users', 'action' => 'edit')), the
call to isPost (requestHandler) will return true.
I can confirm that. This may be a bug, I'll ask nate about it. It basically happens if you don't give an 'action' parameter.

You can style pass 'style' => 'post' with the second method and that
will be seen as a "post".
  
I doubt this would work. I think you can set 'type' => 'post. to work around this.

-- Felix
--------------------------
Blogger: http://www.thinkingphp.org/
Entrepreneur: http://www.posttask.com/ -- currently in private beta, ask me for invite / password
Freelancer: http://www.fg-webdesign.de/

AIM: theundefined87
Skype: TimeFor23
Other IM: felixge.de
Mobile (USA): +1 404 3888693
Mobile (GER): +49 162 9391612
Twitter: http://twitter.com/felixge

francky06l

unread,
Nov 4, 2007, 2:16:15 PM11/4/07
to CakePHP Bleeding Edge
Hi Felix,

You right, if you pass 'type' => 'post', it works (means the
requestHandler->isPost() returns true).
I can confirm that using 'url' => array('controller' => 'Users',
'action' => 'edit'), without 'type', will set the method as "put"..
I have a component that uses requestHandler->isPost(), and was
failing ..

That's the drawback of working with the the branch, in another hand I
learn a lot :-)
Thanks

On Nov 4, 7:45 pm, Felix Geisendörfer <haimu...@gmail.com> wrote:
> > $form->create(array('controller' => 'Users', 'action' => 'edit')), the
> > call to isPost (requestHandler) will return true.
>
> I can confirm that. This may be a bug, I'll ask nate about it. It
> basically happens if you don't give an 'action' parameter.> You can style pass 'style' => 'post' with the second method and that
> > will be seen as a "post".
>
> I doubt this would work. I think you can set 'type' => 'post. to work
> around this.
>
> -- Felix
> --------------------------
> Blogger:http://www.thinkingphp.org/

> Entrepreneur:http://www.posttask.com//-- currently in private beta,
> ask me for invite / password/


> Freelancer:http://www.fg-webdesign.de/
>
> AIM: theundefined87
> Skype: TimeFor23

> Other IM: felixge.de <http://felixge.de/>

nate

unread,
Nov 8, 2007, 11:38:02 AM11/8/07
to CakePHP Bleeding Edge
This is intentional.

On Nov 4, 2:16 pm, francky06l <franckl...@gmail.com> wrote:
> Hi Felix,
>
> You right, if you pass 'type' => 'post', it works (means the
> requestHandler->isPost() returns true).
> I can confirm that using 'url' => array('controller' => 'Users',
> 'action' => 'edit'), without 'type', will set the method as "put"..
> I have a component that uses requestHandler->isPost(), and was
> failing ..
>
> That's the drawback of working with the the branch, in another hand I
> learn a lot :-)
> Thanks
>
> On Nov 4, 7:45 pm, Felix Geisendörfer <haimu...@gmail.com> wrote:
>
> > > $form->create(array('controller' => 'Users', 'action' => 'edit')), the
> > > call to isPost (requestHandler) will return true.
>
> > I can confirm that. This may be a bug, I'll ask nate about it. It
> > basically happens if you don't give an 'action' parameter.> You can style pass 'style' => 'post' with the second method and that
> > > will be seen as a "post".
>
> > I doubt this would work. I think you can set 'type' => 'post. to work
> > around this.
>
> > -- Felix
> > --------------------------
> > Blogger:http://www.thinkingphp.org/

> > Entrepreneur:http://www.posttask.com//--currently in private beta,

Reply all
Reply to author
Forward
0 new messages