Skip to main content
Participant
August 19, 2009
Answered

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

  • August 19, 2009
  • 1 reply
  • 2210 views

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.

    This topic has been closed for replies.
    Correct answer -__cfSearching__-

    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>


    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==-

    1 reply

    August 20, 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

    Participant
    August 20, 2009

    Hi Byron,

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

    August 20, 2009

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