Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

CFFORM method=GET behaves differently in CFMX6.1 than in CF 8 ?

New Here ,
Aug 19, 2009 Aug 19, 2009

Hi Everyone,

My organization is in the process of testing applications for a move from CFMX6.1 to CF8, however, we've found there appears to be a difference between the way CFMX6.1 and CF8 handle the GET method in a CFFORM tag.

I'm not quite sure why our developers would have used the "GET" instead of "POST" to begin with. In the application I'm currently testing, I've found that all but one of the 50+ occurrences of "GET" can be changed to "POST" without issue. However, I am a little concerned with the many other apps we have and the amount of testing that would be required.

Here's what's happening:

CFMX6.1: An appended query string parameter is always part of the submitted url whether the ACTION is POST or GET.

CF 8: A query string parameter appended to a url in the ACTION attribute will be part of the submitted url when the METHOD is POST but not when the METHOD is GET.

To see the above mentioned difference, execute the example code below in both CFMX6.1 and CF8. While executing in CFMX6.1, you will notice when the NEXT button is pressed, the myTestParameter=123 parameter is present in the browsers address bar and the variable will be accessible in the resulting page. This will not be the case when running in CF8

<h3>Test CFFORM POST vs. GET (CFMX6.1 vs. CF 8)</h3>
<cfoutput>
    <table>
        <cfform method="get" action="/Bayerah/gettest.cfm?myTestParameter=123" >      
            <input type="hidden" name="mytestFormVariable" value="abc">
            <tr>
                <td>
                    The CFform tag which is displaying this text contains action="#CGI.Path_Info#?myTestParameter=123"
                    <br /><br />
                    <strong>CF 8</strong><br />                   
                    <p>
                        The query string parameter "myTestParameter=123" will be part of the url when the
                        METHOD is POST and the form is submitted but not when METHOD is GET
                    </p>
                    <br />
                    <strong>CFMX6.1</strong><br />                   
                    <p>
                        The query string parameter "myTestParameter" displays with both POST and GET
                    </p>
                    <br/><br />
                    Press Next to submit the form...
                </td>
            </tr>
            <tr>
                <td>
                    <input type="submit" value="Next">
                </td>
            </tr>
        </cfform>
    </table>
</cfoutput>

Thanks in advance.

2.1K
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines

correct answers 1 Correct answer

Valorous Hero , Aug 20, 2009 Aug 20, 2009

It does not really have anything to do with cfform.  The "method" attribute did not exist in MX6.1. So the form html generated used method="post".

You will see the same behavior in MX6 if you create a plain html form with method="get".

[Edit] A better way to put that last comment is:  should parameters in the action url be honored when the form method is GET. My instinct would be "yes".  But I do not remember what the rfc's specs say about it.

Message was edited by: -==cfSearching==-

Translate
Guest
Aug 19, 2009 Aug 19, 2009

That's curious, what is the actual page source.  The client browser is what actually determines in a "GET" what form variables to pass in the URL.

So I'm wondering if "GET" in a cfform is stripping the action ?varible=somethign portion, but I wouldn't see why.

Byron Mann

mannb@hostmysite.com

byronosity@gmail .com

Lead Software Architect

hosting.com | hostmysite.com

http://www.hostmysite.com/ ?utm_source=bb

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2009 Aug 20, 2009

Hi Byron,

Ya agree, it's definatety the CFFORM that's peeling away the action ?varible=value portion.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Aug 20, 2009 Aug 20, 2009

Played around a bit, change the input to a cfinput and all seems well.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 20, 2009 Aug 20, 2009

Hi Byron,

Nope still doesn't pull back the myTestParameter variable even with CFINPUT. You may have mistaken the two variables. If you add the following to the end of the code snip just before the </CFOUPUT> you will see that in CF8 the variable myTestParameter is never available.

 
<cfif isdefined ("url.myTestParameter")>
url.myTestParameter = #url.myTestParameter#
</cfif>

<cfif isdefined ("url.mytestFormVariable")>
url.mytestFormVariable = #url.mytestFormVariable#
</cfif>

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 20, 2009 Aug 20, 2009

It does not really have anything to do with cfform.  The "method" attribute did not exist in MX6.1. So the form html generated used method="post".

You will see the same behavior in MX6 if you create a plain html form with method="get".

[Edit] A better way to put that last comment is:  should parameters in the action url be honored when the form method is GET. My instinct would be "yes".  But I do not remember what the rfc's specs say about it.

Message was edited by: -==cfSearching==-

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Aug 21, 2009 Aug 21, 2009

That completely explains what's going on. Thank-you very much -==cfSearching==- for your response.

Since MX6.1 always uses the "POST" method regardless of whether a method="GET" is coded, I now feel comfortable globally replacing all occurrences of method="GET" to method="POST".

I think I now understand what could have happened, the developers were probably using the regular html <Form> tag with method="GET" and later adopted the <CFForm> tag approach to take advantage of validation javascript produced by CF when it detects attributes like required="yes" in <CFInput> tags.

Last word. I also think that url variables in the ACTION attribute should be honored.

Thanks Again for your explanation

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Valorous Hero ,
Aug 24, 2009 Aug 24, 2009
LATEST
Last word. I also think that url variables in the ACTION attribute should be honored.

Yes, I was torn about that.  Though there is really no need to use url parameters with method="get", it just seemed a little counterintutive. At least  given how one normally works with urls.  But after looking at the spec's, it seems like this is the intended behavior and that the parameters should be ignored.


http://www.w3.org/TR/html401/interact/forms.html#h-17.13.1
With the HTTP "get" method, the form data set is appended to the URI specified by the action attribute (with a question-mark ("?") as separator) and this new URI is sent to the processing agent.

Anyway, I am glad I could help.

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources