BranchCMS Upgrades

Eric Tompkins
Oct 14, 2010

Using URL Request Parameters as the Default Value for Form Fields

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: 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 {} 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}.

Sign up for our newsletter to receive invaluable information about BranchCMS, web design & development.