2011-03-23
 
Kategorie
 

Filling in Fields with URL Parameters

 

ActiveForms allows us to pre-fill fields by supplying values in form address parameters. For example, if our form is available at

https://activeforms.com/firma/formularz

and has ‘first_name’ and ‘last_name’ fields, then calling the

https://activeforms.com/firma/formularz?first_name=Jacek&last_name=Romanowski

address will display the form with the first_name and last_name fields filled in with the supplied values.

Pre-filling fields using URL parameters doesn’t change their behaviour. If a field is visible and enabled, users can change its value. If the field is hidden or inactive, no change is possible.

This mechanism allows you to implement many interesting features:

  • You can track where users arrive from: you can embed links to your form on various sites with different values of a specific parameter, e.g. partner_id.
  • If a user accesses the form from a system where he or she has already been authenticated, you can pass the user’s data (first and last name) to the form, so that the user doesn’t have to enter them manually.
  • By passing a value to the form using a URL parameter, you can control the behaviour of the form. For example, you can pass a flag to a hidden field so that specific fragments of the form will be hidden by ActiveForms mechanisms. Consequently, the form can behave in different ways, depending on how it is called (i.e. what the values of the passed argument are).

Field values can be passed via an URL for all field types, except for File Upload and CAPTCHA fields. When assigning values to fields, follow these principles:

  • Field values have to be formatted with URL encoding.
  • For Drop-down list and Radiobutton list fields, provide the value of one of the field options.
  • For Checkbox list and Multichoice fields, also provide option values. To select multiple options, pass the parameter multiple times.
  • To set the value of a Confirmation checkbox field, pass either of the values specified in the field configuration as the yes_value or no_value.
  • Set the date in the format defined for a given field (in the integration format, if specified).
  • To set a Multifield field value, pass a string containing all separators defined for the given multifield in a sequence. The consecutive components of the multifield are filled with strings between the consecutive separators (or left empty).
  • If a field with a default value needs to be cleared, pass a parameter with the “” value (an empty string). This applies to all field types.

If the form address contains a parameter that doesn’t correspond with any field, the parameter will be ignored. Similarly, if an option list field receives a value not from the list, the parameter will also be ignored.

 
 
recent posts
3rd Apr 2014
Faster than ever!
5th Dec 2013
Live validation!
2nd Dec 2013
Features distilled
12th Mar 2012
Flicking Channels
26th Jan 2012
Your Own Error Page
9th May 2011
Box Properties
15th Apr 2011
Grouping Fields
13th Apr 2011
Form Versioning
24th Feb 2011
Form Access Modes
22nd Feb 2011
Required Fields
4th Feb 2011
Stats!