I also did read that in the book.
But in this case I went thru the site last night and found 10 forms that will
all update an existing record.
Basically user goes to a page (edit profile) and all the info is populated in
the form / ajax submit saved alert. Pretty basic.
All the forms submit the same, all thru the same javascript (method : POST) but
the profile page changes to PUT.
Cake does not change any of the other forms, just my edit/profile.
$this->Form->create('User', array(………..)) Form->end() all that tasty goodness.
From: [email protected] [mailto:[email protected]] On Behalf Of
Irvin Huang
Sent: Thursday, May 09, 2013 11:13 AM
To: [email protected]
Subject: Re: POST form changes to PUT
According to CakePHP > lib > Cake > View > Helper > FormHelper.php
Look up to this function
public function create($model = null, $options = array())
and the following is the conditions the FormHelper will change PUT to POST:
1. Either $this->request->data[ the model name same as you specified for
$this->Form->create(… ] doesn't exist OR you do pass "action" value to
$this->Form->create.
2. $this->request->data[MODEL NAME]['id'] doesn't exist.
my thought:
I think CakePHP has been clearly these things POST and PUT. You saving new
record by POST and modifying by PUT.
Advantage+ <[email protected]> 於 2013/5/9 上午6:40 寫道:
I will see what I can find out tonight and sure to share any results.
Dave
From: [email protected] [mailto:[email protected]] On Behalf Of
André Luis
Sent: Wednesday, May 08, 2013 6:28 PM
To: [email protected]
Subject: Re: POST form changes to PUT
Maybe a ghost chaning it´s value everytime you are not looking at...
If you find why it´s happening please share here, because i have same issue
sometimes...
Em quarta-feira, 8 de maio de 2013 17h29min54s UTC-3, advantage+ escreveu:
I am same, 2.3.4
It works fine as I stated in every form except just this one.
Nothing special just allows user to edit the profile data. Name / country / bio
and sent to the same js function as every other form on the site. Every form as
you noted has that hidden div and all point to _post except this 1 form gets
changed to _put.
It is not the functionality that has me puzzled, its figuring out why just this
form. I know I can do the post || put in the controller but rather figure out
why this is happening rather than just side track it with extra params in the
controller since it should not be needed.
Will look thru everything again see if there is something over looked….
Thanks,
Dave
From: <javascript:> [email protected] [mailto: <javascript:>
[email protected]] On Behalf Of André Luis
Sent: Wednesday, May 08, 2013 5:48 PM
To: <javascript:> [email protected]
Subject: Re: POST form changes to PUT
What is your CakePHP core version? I´ve tested on 2.3.4 here and worked fine.
Also i´m under PHP 5.4, check your PHP version too (But i think there is no
reason for not working)
Em quarta-feira, 8 de maio de 2013 14h58min21s UTC-3, advantage+ escreveu:
I have it hardcoded like that for this form. Still goes to PUT.
From: <mailto:[email protected]> [email protected]
<mailto:[mailto:[email protected]]> [mailto:[email protected]] On
Behalf Of Mancho
Sent: Wednesday, May 08, 2013 9:17 AM
To: <mailto:[email protected]> [email protected]
Subject: Re: POST form changes to PUT
Actually with option type you can change the hardcoded method.
echo $this->Form->create('User', array('type' => 'post'));
Murgan, Alexis Germán
Desarrollador & Diseñador
Web: <http://german.murgan.com.ar> german.murgan.com.ar
Email: <mailto:[email protected]> [email protected]
MSN: <mailto:[email protected]> [email protected]
Móvil: +5493424663813
2013/5/8 André Luis < <mailto:[email protected]> [email protected]>
What if you create a hidden field "
$this->Form->hidden('_method',array('name'=>'_method','value'=>'POST')) " in
your form?? It should override the other one
Em segunda-feira, 6 de maio de 2013 15h47min55s UTC-3, advantage+ escreveu:
Running into a weird issue where my form as rendered the HTML shows:
<form id="EditProfile" class="form-horizontal" accept-charset="utf-8"
method="post" action="/manage/profile">
This form is submitted using ajax and the function is used by many forms thru
the site:
$.ajax({
type: "POST",
url: $(sel).attr('action'),
data: $(sel).formSerialize(),
dataType: 'json',
And in the controller I have if($this->request->is('ajax') &&
($this->request->is('post'))
But it fails on this 1 form because for some reason it is changing to PUT.
Are there reason why this would be happening? I looked at a few of my forms
using this js function and all of the forms and all are set up the exact same
way / Form->helper standard inputs / selects.
I even added into the form with issues 'method' => 'POST' (upper and lower) but
it still fires off a PUT request. Renders as POST but inspecting the request
shows:
application/x-www-form-urlencoded
_methodPUT
Ideas would be welcome.
--
Like Us on FaceBook <https://www.facebook.com/CakePHP>
https://www.facebook.com/CakePHP
Find us on Twitter <http://twitter.com/CakePHP> 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 <mailto:[email protected]> [email protected].
To post to this group, send email to <mailto:[email protected]>
[email protected].
Visit this group at <http://groups.google.com/group/cake-php?hl=en>
http://groups.google.com/group/cake-php?hl=en.
For more options, visit <https://groups.google.com/groups/opt_out>
https://groups.google.com/groups/opt_out.
--
Like Us on FaceBook <https://www.facebook.com/CakePHP>
https://www.facebook.com/CakePHP
Find us on Twitter <http://twitter.com/CakePHP> 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 <mailto:[email protected]> [email protected].
To post to this group, send email to <mailto:[email protected]>
[email protected].
Visit this group at <http://groups.google.com/group/cake-php?hl=en>
http://groups.google.com/group/cake-php?hl=en.
For more options, visit <https://groups.google.com/groups/opt_out>
https://groups.google.com/groups/opt_out.
--
Like Us on FaceBook <https://www.facebook.com/CakePHP>
https://www.facebook.com/CakePHP
Find us on Twitter <http://twitter.com/CakePHP> 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 <javascript:> [email protected].
To post to this group, send email to <javascript:> [email protected].
Visit this group at <http://groups.google.com/group/cake-php?hl=en>
http://groups.google.com/group/cake-php?hl=en.
For more options, visit <https://groups.google.com/groups/opt_out>
https://groups.google.com/groups/opt_out.
--
Like Us on FaceBook <https://www.facebook.com/CakePHP>
https://www.facebook.com/CakePHP
Find us on Twitter <http://twitter.com/CakePHP> 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 <mailto:[email protected]>
[email protected].
To post to this group, send email to <mailto:[email protected]>
[email protected].
Visit this group at <http://groups.google.com/group/cake-php?hl=en>
http://groups.google.com/group/cake-php?hl=en.
For more options, visit <https://groups.google.com/groups/opt_out>
https://groups.google.com/groups/opt_out.
--
Like Us on FaceBook <https://www.facebook.com/CakePHP>
https://www.facebook.com/CakePHP
Find us on Twitter <http://twitter.com/CakePHP> 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 <mailto:[email protected]>
[email protected].
To post to this group, send email to <mailto:[email protected]>
[email protected].
Visit this group at <http://groups.google.com/group/cake-php?hl=en>
http://groups.google.com/group/cake-php?hl=en.
For more options, visit <https://groups.google.com/groups/opt_out>
https://groups.google.com/groups/opt_out.
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
--
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.