Wiki source code of URL-Parameter


Hide last authors
gru 1.1 1 {{content/}}
2
gru 5.2 3 When you open a form, you can add additional parameters to the URL of the form to prefill some form fields. You need to separate URL parameters from the main URL by adding a question mark **?**. If you need multiple parameters, separate them with an ampersand **&**. This results the following pattern for the URL:
gru 1.1 4
5 {{code language="none"}}
gru 5.2 6 http://<host>//formcycle/form/alias/1/demo?<field1Name>=<field1Value>&<field2Name>=<field2Value>&...
gru 1.1 7 {{/code}}
8
gru 5.2 9 Please note that when you need to use special characters, you need to [[escape them>>url:https://en.wikipedia.org/wiki/Percent-encoding]]. For example, to specify an URL parameters named //tfCompany// with the value //Clark & Joe Ltd.//:
gru 1.1 10
11 {{code language="none"}}
gru 5.2 12 http://<host>//formcycle/form/alias/1/demo?tfCompany=Clark%20%26%20Joe%20Ltd.
gru 1.1 13 {{/code}}
14
gru 5.2 15 == Using URL parameters ==
gru 1.1 16
gru 5.2 17 You can use URL parameters to prefill form fields both when the form is opened for the first time as well as when a saved or submitted form is opened again. Please note that existing form field values are overwritten when URL parameters are used.
gru 1.1 18
gru 5.2 19 == Examples ==
gru 1.1 20
gru 5.2 21 === Prefilling an input field ===
gru 1.1 22
gru 5.2 23 {{figure image="designer_url_param_textfield_en.png"}}
24 Setup in the {{designer/}} for prefilling an input field.
gru 1.1 25 {{/figure}}
26
gru 5.2 27 {{figure image="designer_url_param_textfield_demo_en.png"}}
28 When opening the form, we set the URL parameter //tfMail//. This sets the initial value of the corresponding input field.
gru 1.1 29 {{/figure}}
30
gru 5.2 31 Create a [[input field>>doc:Formcycle.Designer.Form.FormElements.Input]] with the name //tfMail//. When you open the form, add the URL parameter //tfMail// and set it to an email address. The URL could look like:
gru 1.1 32
33 {{code language="none"}}
gru 5.2 34 http://<host>/formcycle/form/alias/1/demo?tfMail=johndoe@example.com
gru 1.1 35 {{/code}}
36
gru 5.2 37 As shown in the figure to the right, this sets the initial value of the input field to the given email address.
gru 1.1 38
gru 5.2 39 === Prefilling a select field ===
gru 1.1 40
gru 5.2 41 {{figure image="designer_url_param_select_en.png"}}
42 Setup in the {{designer/}} for prefilling a select field.
gru 1.1 43 {{/figure}}
44
gru 5.2 45 {{figure image="designer_url_param_select_demo_en.png"}}
46 When opening the form, we set the URL parameter //selSex//. This sets the initial value of the corresponding select field.
gru 1.1 47 {{/figure}}
48
gru 5.2 49 You can preselect an option of a [[select field>>doc:Formcycle.Designer.Form.FormElements.Selection]] as well. Note that you cannot use the displayed name as the value of the URL parameter. You need to use the value specified in the //values// column of the options section in the properties panel of the {{designer/}}.
gru 1.1 50
gru 5.2 51 Create a select field with the name //selSex//. When you open the form, add the URL parameter //selSex// and set it to //f//. The URL could look like:
gru 1.1 52
53 {{code language="none"}}
gru 5.2 54 http://<host>/formcycle/form/alias/1/demo?selSex=f
gru 1.1 55 {{/code}}
56
gru 5.2 57 As shown in the figure to the right, this preselects the option //female//.
gru 1.1 58
59 {{info}}
gru 5.2 60 You cannot prefill [[repeated elements>>doc:Formcycle.Designer.Form.ElementProperties.BaseProperties||anchor="repeat"]]. It is also not possible to set the initial number of repetitions via URL parameters.
gru 1.1 61 {{/info}}
62
gru 5.2 63 === Changing the form layout ===
gru 1.1 64
gru 5.2 65 {{figure image="CSSTheme_eng.PNG"}}
66 To open a form with a different layout (CSS theme), use the URL paramter //xfc-rp-theme// and pass the UUID of the CSS theme as the value. The UUID is shown in the details panel (1) to the right hand side of the //Layout (CSS)// menu.
gru 1.1 67 {{/figure}}
68
gru 5.2 69 You can create different form layouts (CSS themes) in the [[Layout (CSS)>>Formcycle.UserInterface.FilesAndTemplates.Layout]] menu. You can then assign one form layout to each form. If you want to open a form with a different layout, such as a blue or red variation of your main theme, you can use an optional URL parameter.
gru 1.1 70
gru 5.2 71 The name of the URL parameter is //xfc-rp-theme//, and its value needs to be the UUID of the form layout. You can view the UUID of each form layout in the [[Layout (CSS)>>Formcycle.UserInterface.FilesAndTemplates.Layout]] menu (see screenshot to the right).
gru 1.1 72
gru 5.2 73 For example:
74
gru 1.1 75 {{code language="none"}}
gru 5.2 76 http://<host>/formcycle/form/alias/1/demo?xfc-rp-theme=<UUID>
gru 1.1 77 http://<host>/formcycle/form/alias/1/demo?xfc-rp-theme=8b4a9c2d-34d9-4cff-8759-9b54ed4b0ff1
78 {{/code}}