You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Iss # 483 - open local files + redesign of Form Layout page (#490)
* update default values
* open local files using default values
* using html widget to open local files
* mobile app redesign - screenshots update
* fix broken link
Copy file name to clipboardExpand all lines: src/layer/form-layout/index.md
+44-9Lines changed: 44 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -3,9 +3,6 @@
3
3
4
4
Collecting and editing data in the field can be more efficient with forms that are easy to navigate. QGIS offers a lot of options for improving the layout of your forms, such as using groups and tabs to keep related fields together, displaying or hiding a group of fields based on conditional visibility, or displaying tips and instructions in the forms.
5
5
6
-
::: warning
7
-
Our mobile app was redesigned. We are in the process of updating this content to reflect these changes.
8
-
:::
9
6
10
7
## QGIS Drag and Drop Designer
11
8
By default, the form is automatically generated and contains all the fields in the layer. However, you might want to change the order of the fields. Also, there may be some fields that do not need to be displayed during the survey, such as fields with [default values](../settingup_forms_settings/#default-values) that are calculated from the geometry.
@@ -45,22 +42,27 @@ The form with tabs and groups will appear in QGIS like this:
45
42

46
43
47
44
And this is how the same form looks like in <MobileAppName />:
48
-

45
+

49
46
50
47
51
48
## Show and hide fields depending on a field value
52
49
Conditional visibility can be applied to groups and tabs, meaning they will be displayed or hidden depending on the value of a field.
53
50
54
-
We can set the visibility of **Location** tab depending on the value of the **survey** field:
55
-
- If **survey** is set to **False**, the **Location** tab will not appear in the form,
56
-
- If **survey** is set to **True**, the **Location** tab will show up in the form.
51
+
We can set the visibility of **Location** tab depending on the value of the `survey` field:
52
+
- If `survey` is set to `False`, the **Location** tab will not appear in the form,
53
+
- If `survey` is set to `True`, the **Location** tab will show up in the form.
57
54
58
55
1. Select the **Location** tab in the **Form Layout** column
59
56
2. Check the **Control Visibility by Expression** option
60
57
3. Type the following expression in the box below: `"survey" IS TRUE`
61
58
4. Background colour can be set in the **Style** tab.
59
+
62
60

63
61
62
+
In the <MobileAppNameShort />, the tab **Location** is displayed only when the `survey` field (aliased here as *Does it need surveying*) is toggled to `true`.
63
+

64
+
65
+
64
66
## Display instructions in the form using Text and HTML widget
65
67
Sometimes, you may want to include instructions or tips for surveyors in your forms. <QGISlink=""text="QGIS" /> offers Text and HTML widgets that can be used for this purpose. Your text instructions can include [expressions and field values](#using-expressions-in-text-and-html-widgets) as well. The HTML widget supports various [HTML tags](https://doc.qt.io/qt-6/richtext-html-subset.html#supported-tags), so it can be also used, for instance, to display [online images](#using-html-widget-to-display-online-images-and-other-online-resources).
66
68
@@ -74,7 +76,7 @@ If you prefer your text to be formatted, you may do so in the **HTML** widget. H
74
76

75
77
76
78
...and this is how the Text and HTML widgets look like in the form in QGIS (left) and in the mobile app (right).
77
-

79
+

78
80
79
81
### Using expressions in Text and HTML widgets
80
82
Expressions and variables can be used both in the Text and the HTML widget.
@@ -105,6 +107,10 @@ Clone <MerginMapsProject id="documentation/form_cascade" /> to follow this examp
105
107
### Using HTML widget to display online images and other online resources
106
108
The **HTML widget** can be also used to display online images in the mobile app or open online resources, such as PDF files, videos or websites, in the browser of your device.
107
109
110
+
::: tip
111
+
Clone <MerginMapsProjectid="documentation/forms-display-images-and-files" /> to how this works.
112
+
:::
113
+
108
114
Here are HTML samples you can use to [configure the HTML widget](#using-expressions-in-text-and-html-widgets). Your form should contain a text field for storing the full URL link (here: `link`).
109
115
110
116
To use these samples, replace `link` by the name of the appropriate field in your layer.
@@ -120,10 +126,39 @@ To use these samples, replace `link` by the name of the appropriate field in you
120
126
<script>document.write(expression.evaluate("'<a href=\"'||attribute( @feature, 'link' )||'\">here is your link</a>'"));</script>
121
127
```
122
128
123
-
Make sure that the HTML widget works as intended before taking it to the field - try it out in QGIS and in the <MobileAppNameShort />. It should look something like this:
129
+
Make sure that the HTML widget works before taking it to the field by testing it in the <MobileAppNameShort />. It should look something like this:
124
130
125
131

126
132
133
+
::: warning Image preview in QGIS 3.36+
134
+
QGIS may not display the preview of the online image if you use QGIS 3.36 or higher. Despite this behaviour, the <MobileAppNameShort /> displays it correctly. Therefore we recommend trying the setup by opening the form in the <MobileAppNameShort /> to make sure it works as intended.
135
+
:::
136
+
137
+
138
+
### Using HTML widget to open local files
139
+
The HTML widget can also be used to open local files: for instance, a locally stored PDF file can be opened from within the form during the survey.
140
+
141
+
::: tip
142
+
Clone <MerginMapsProjectid="documentation/forms-display-images-and-files" /> to how this works.
143
+
:::
144
+
145
+
- A PDF file named `my-pdf.pdf` is stored in the main [project folder](../../manage/project/#mergin-maps-project-folder) as it needs to be packaged with the project.
146
+
- The HTML Widget is added to the **Attributes Form** and configured as follows:
147
+
```
148
+
<a href="project://my-pdf.pdf">Open File</a>
149
+
```
150
+
151
+

152
+
153
+
In the <MobileAppNameShort />, you can tap the *Open File* link to open the PDF file using the default application of your device.
154
+
155
+

156
+
157
+
::: tip Open local files using default values
158
+
Local files can be displayed in the form also using [default values](../settingup_forms_settings/#open-local-files-using-default-values).
159
+
160
+
In the <MerginMapsProjectid="documentation/forms-display-images-and-files" /> project, you can explore and compare both alternatives.
|`@mergin_username`|`martin`| global | Name of the user currently logged in to <MainPlatformNameLink /> |
8
-
|`@mergin_user_email`|`martin@example.com`<SinceBadgetype="App"version="2.5.0" />| global | Email of the user currently logged in to <MainPlatformName />|
8
+
|`@mergin_user_email`|`martin@example.com`| global | Email of the user currently logged in to <MainPlatformName />|
9
9
|`@mergin_url`|`https://app.merginmaps.com`| global | URL of the <MainPlatformName /> service |
10
10
|`@mergin_project_name`|`Tree survey`| project | Name of the active <MainPlatformName /> project |
11
11
|`@mergin_project_owner`|`martin`| project | Name of the owner of the active project |
Copy file name to clipboardExpand all lines: src/layer/settingup_forms_photo.md
+3Lines changed: 3 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -102,3 +102,6 @@ Now when you click on a feature that contains a photo, it will be displayed in t
102
102
103
103

104
104
105
+
::: warning Image preview in QGIS 3.36+
106
+
QGIS may not display the preview of the image if you use QGIS 3.36 or higher. Despite this behaviour, the <MobileAppNameShort /> displays it correctly. Therefore we recommend trying the setup by opening the form in the <MobileAppNameShort /> to make sure it works as intended.
Copy file name to clipboardExpand all lines: src/layer/settingup_forms_settings.md
+41Lines changed: 41 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -37,6 +37,47 @@ When you survey a new point in <MobileAppName />, you will see the values are au
37
37
38
38

39
39
40
+
### Examples of useful default values
41
+
There are some commonly used default values that can be useful in your field survey. As they are filled in automatically, they can be hidden from attributes form.
42
+
43
+
* It is convenient to know when a feature was created and when it was last updated. Use fields with **Date** or **Date&Time** data types with the `now()` function to record these information. You can change the formatting using [Date/Time](./settingup_forms/#date-and-time) widget.
44
+
* Similarly, the name of the <MainPlatformName /> user who created or modified the feature can be recorded using the `@mergin_username`[QGIS plugin variable](./plugin-variables/). These field should have the **Text (string)** data type.
45
+
* The coordinates of a point feature can be recorded as well using the `$x` and `$y` function in QGIS. To record the coordinate accurately, these fields should have the **Decimal number (real)** data type. If the coordinates are in meters, values can be rounded to, say, 2-3 decimal places. When working with geographic coordinates that use degrees, you may want to round the coordinates to 8 decimal places. Use the *apply default value on update* option so that you have correct values when the position of the point feature changes.
46
+
47
+
48
+
| Variable name | Sample value | Apply default value on update | Description |
|`@now`|`2024-06-30 10:00:00`|**no**| The timestamp of when the feature was created. |
51
+
|`@now`|`2024-06-30 10:30:00`|**yes**| The timestamp of when the feature was last **updated**. |
52
+
|`@mergin_username`|`sarah`|**no**| Name of the user who created this feature.|
53
+
|`@mergin_username`|`jack`|**yes**| Name of the user who **updated** this feature last.|
54
+
|`round($x,2)`|`1898789.92`|**yes**| The X coordinate of a point feature, rounded to 2 decimal places.|
55
+
|`round($y,2)`|`6134520.89`|**yes**| The Y coordinate of a point feature, rounded to 2 decimal places.|
56
+
57
+
### Open local files using default values
58
+
Default values can also be used to open local files (e.g. a PDF file) from within the form. This file needs to be packaged with the project, so it should be stored somewhere in the [project folder](../manage/project/#mergin-maps-project-folder).
59
+
60
+
There is a public project <MerginMapsProjectid="documentation/forms-display-images-and-files" /> you can download or clone to see how the setup works.
61
+
- A PDF file named `my-pdf.pdf` is stored in the main project folder.
62
+
- The survey layer has a field named `local-file-default-value` with **Text (string)** data type.
63
+
- This field is set to *not editable* (the form will refer to the same file for all features and does not need to be changed).
64
+
- This field uses the **Text Edit** widget with the *Multiline* and *HTML* options enabled.
65
+
- The **default value** is set to:
66
+
```
67
+
'<a href="project://my-pdf.pdf">Open File</a>'
68
+
```
69
+
70
+

71
+
72
+
In the <MobileAppNameShort />, you can tap the *Open File* link to open the PDF file using the default application of your device.
73
+
74
+

75
+
76
+
::: tip Open local files using the HTML widget
77
+
Local files can be displayed in the form also using [the HTML widget](./form-layout/#using-html-widget-to-open-local-files).
78
+
79
+
In the <MerginMapsProjectid="documentation/forms-display-images-and-files" /> project, you can explore and compare both alternatives.
80
+
:::
40
81
41
82
## Constraints
42
83
When collecting data, you may want to apply constraints to certain field(s) to avoid mistakes when the values are filled in in the field.
0 commit comments