Using URL Request Parameters as the Default Value for Form Fields

Oct
14
2010

Sliced Design, one of our partners, recently contacted us with a great feature request. They were building a site with a contact form that needed to have some dynamic default values for some of it's fields. In the site they have links to the form that look like this: site.com/contact?name=Joe. They needed to have the "Name" text box automatically filled with the value from the "name" URL parameter.

Now on the surface this isn't that bad of a request. In their form template they could simply put in some logic to see if the {#global.request.get.name} value exists and then set the value for the Name field. Their request was to make this easier. They simply wanted to set the variable as the default value when setting up the form field.

We went to work and made that happen.

Setting form field default value with variables

You can now use any of the {#global} variables as the default value for form fields. (See the Global Tags documentation for more information on Global Tags.) We also took it a step further and you can also use Form Variables as a default value. You would use the same variable that you would in Form Templates: {#form.variables.registration-number}.

2 Comments on "Using URL Request Parameters as the Default Value for Form Fields"

October 15, 2010 12:52 PM
Jeremy Hamel says:
Thanks guys! The client loves the feature. So easy to implement and it works perfectly!
October 18, 2010 10:49 AM
Eric Tompkins says:
I'm glad that it worked well for you.

Leave a comment