Default values as URL parameters

Use URL parameters to set default values in the form

URL parameters are an interesting feature. URL parameters open up the possibility of filling the fields in a form with individual default values via the link with which the form is called up.

URL parameters are very easily accessible. The feature can therefore theoretically be used by malicious users to manipulate and abuse a form. Therefore, this feature received some special security measures during development.

Allow use of URL parameters

By default, the use of URL parameters is disabled for all fields. If you want to use URL parameters to set a default value for a field, you must explicitly activate this in the field settings. On the “Advanced” tab, set the “Allow URL parameters” parameter to “yes”. This is a security measure.

Format of URL parameters

Any number of parameters of the form name=value can be appended to a URL.
A question mark ? must precede the first parameter in a URL.
However, between several parameters there is an ampersand &.

The complete URL then looks like this:

The parameter name

The exact parameter name you need to use in your URL to set a default value for a particular field depends on how you published the form.

Form published as a menu item

If the form is published via a menu item of the type Visforms » Form, then the parameter name is made up as follows:

"form" + ID of the form + value in the "Name" option of the field

For example, if you have a field in the form with ID 3 that has the value “name” in the “Name” option, you can address this using the parameter name form3name.

Form published as Visforms module

If the form is published via a Visforms module, the parameter name is composed as follows:

"modvisforms" + ID of the module + value in the "Name" option of the field

For example, if you published the above form with the ID 3 via a Visforms module that has the module ID 318, then you can reach the above field in this form using the parameter name modvisforms318name.

The parameter value

The parameter value is a character string that is later to be used as the default value in the form field. For security reasons, only character strings can be passed as parameter values.

If the field is an input field in which text can be entered, you can specify any default value. If, on the other hand, it is a list box, a radio button, a checkbox group or a checkbox, these fields have a list of permitted parameter values, and you must pass such a permitted value. All values that you have entered in the field configuration in the option list as the respective option value are permitted. The option that matches this value is then selected in the form.

Special features for list boxes and check box groups

Hinweis: For list boxes and checkbox groups, '[]' must be appended to the parameter name.

List boxes and check box groups may have more than one option selected by default on the form. This is why you can pass several name[]=value pairs for a listbox or a checkbox group. Each name[]=value pair corresponds to a preselected option.

A form with the ID 1 serves as an example. It is published via a menu item and contains a list box named “select”. The list box contains the options s1||choice1, s2||choice2, s3||choice3 and the first two options should be preselected.

The full string to append to the URL is then

  • for a URL that doesn’t already contain any other parameters:
  • for a URL that already contains other parameters:

Which value is finally displayed in the form?

If the user calls up a website that contains a Visforms form, it is first checked for each form field whether a default value has been set in the field configuration. If so, this default value is adopted.

It is then checked whether URL parameters are permitted for the field and, if so, whether a parameter has been set in the URL. If so, any existing default value is overwritten with the value of the URL parameter.

If a form that has already been filled out and submitted is displayed again due to a violation during the PHP-side validation, the user input already made is displayed again.

Visibility of the URL parameter in the form

You can also use a URL parameter just to write it, along with the other field values, to the form’s data table after the form is submitted.

User should not be able to see or edit the value

Assuming the user should neither be able to see nor edit the value of the URL parameter. You must use a ‘hidden’ type field in this case.

Users should be able to see the value but not edit it

Suppose the user should be able to see the value of the URL parameter but not edit it. In this case, you must activate the ‘Read Only’ parameter checkbox on the ‘Basic Options’ tab in the configuration for the affected field.

Building the URL

Links with URL parameters currently always have to be created manually. It is not possible to create a menu for a form and add URL parameters directly to this menu in the configuration. However, you can use the URL for the menu as a basis and then call it up from articles and manually add the desired URL parameters.

Application example

Use case

You are an event organizer. There is a page for each individual event. On these pages there is a description of the event and a link to a joint registration form. So you have a central registration form that is used to register for all events.

You want to make registration as easy as possible for users of your website. Certain fields of the registration form, such as the date of the event and the name of the event, should be automatically filled with the data appropriate to the respective event. Depending on the event from which the form was called.


You can easily implement the use case described above using only URL parameters.

Add a date field to the form for the event date. Add a Listbox type field to the form. Create a separate option for each of the events for a list box type field. Now enable the use of URL parameters for the date field and the event selection list box. Create a Visforms type menu that links to the form.

Use the link to this menu as the base link for the actual link to the registration form. Enter the basic link manually in the desired place on the respective event pages.

Finally, append the two event-specific information as URL parameters to the basic link to the registration form. If the user now clicks on the link in one of the event pages, he will be taken to the form and the date and event name will already be set correctly.