Skip to content

Commit 865bcc5

Browse files
committed
form widgets
1 parent 71a8f7c commit 865bcc5

File tree

3 files changed

+27
-96
lines changed

3 files changed

+27
-96
lines changed

src/layer/info-widgets/index.md

Lines changed: 4 additions & 76 deletions
Original file line numberDiff line numberDiff line change
@@ -1,78 +1,6 @@
1-
# Attributes Form Layout
1+
# Informational Widgets
22
[[toc]]
33

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-
6-
7-
## QGIS Drag and Drop Designer
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](../form-configuration/#default-values) that are calculated from the geometry.
9-
10-
QGIS Drag and Drop designer is an easy tool for defining the form layouts:
11-
1. Open your <MainPlatformNameLink /> project in QGIS
12-
2. Right-click on a layer and select **Properties**
13-
3. Navigate to the **Attributes form** tab. Here, switch to **Drag and Drop Designer**
14-
4. Fields can be added and removed from the **Form Layout**. The order of the fields can be changed by simply dragging them higher or lower in the list.
15-
16-
Only fields that are in the **Form layout** will appear in the form.
17-
18-
5. Click **OK** to confirm your changes.
19-
20-
![QGIS drag and drop form designer](./qgis-drag-n-drop.gif "QGIS drag and drop form designer")
21-
22-
## Tabs and groups
23-
Using QGIS Drag and Drop designer, fields can be arranged into groups and tabs.
24-
25-
:::tip Example project available
26-
To see an example of tabs and groups, you can clone <MerginMapsProject id="documentation/form_setup" />.
27-
:::
28-
29-
1. Click on the **+** button to add new group or a tab to the form layout
30-
![QGIS Drag and drop designer add new group or tab](./qgis-form-layout-add-groups-tabs.jpg "Add new group or tab button")
31-
2. Choose the container type, add a label, and if needed, the number of columns.
32-
33-
A group can be placed within a tab or another group.
34-
![QGIS form Add tab](./qgis-add-group-tab.jpg "QGIS form Add tab")
35-
![QGIS form Add group](./qgis-form-add-group.jpg "QGIS form Add group")
36-
37-
3. Drag and drop fields to tabs or groups as needed.
38-
39-
Here we have two tabs, *Data* and *Changelog*. The *Data* tab contains two groups: *roads* and *paths*.
40-
![QGIS form with tabs and groups](./qgis_forms_layout.jpg "QGIS form with tabs and groups")
41-
42-
The form with tabs and groups will appear in QGIS like this:
43-
![QGIS form layout with tabs and groups](./qgis-form-tabs-groups.jpg "QGIS form layout with tabs and groups")
44-
45-
And this is how the same form looks like in the <MobileAppNameShort />:
46-
![Mergin Maps mobile form with tabs and groups](./mobile-forms-layout.jpg "Mergin Maps mobile form with tabs and groups")
47-
48-
49-
## Show and hide fields depending on a field value (conditional visibility)
50-
Conditional visibility can be applied to groups and tabs, meaning they will be displayed or hidden depending on the value of a field.
51-
52-
:::tip Example project available
53-
You can explore this functionality in <MerginMapsProject id="documentation/form_setup" />.
54-
:::
55-
56-
Here we will use a line layer named `roads and paths`. It is designed for surveying both roads and paths and most of the fields are relevant for every type of feature in this layer. However, there are some attributes that are specific for roads (e.g. the number of lanes) or for paths (e.g. the visibility of the path).
57-
58-
The form uses the value of the `type` field to display the relevant set of attributes. The `type` field is set up as [value map](../form-widgets/#value-map) with defined values `road` and `path`.
59-
60-
![QGIS form value map](./qgis-form-value-map-roads.jpg "QGIS form value map")
61-
62-
To set the visibility of groups in the attributes form:
63-
1. Click on the **roads** group in the **Form Layout**
64-
2. Check the **Control Visibility by Expression** option :heavy_check_mark:
65-
3. Define the expression. Here we use: `"type" = "road"`
66-
67-
![QGIS form control visibility by expression](./qgis-form-conditional-visibility.jpg "QGIS form control visibility by expression")
68-
69-
4. Same steps are used for the **path** group using the expression `"type" = "path"`
70-
71-
In the <MobileAppNameShort />, the form displays these groups only when the condition is met. So, there are different sets of attributes depending on the value that is entered in the `type` field.
72-
73-
![Show fields depending on a field value in the mobile app](./mobile-forms-conditional-visibility.jpg "Show fields depending on a field value in the mobile app")
74-
75-
764
## Display instructions in the form using Text and HTML widget
775
Sometimes, you may want to include instructions or tips for surveyors in your forms. <QGIS link="" 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).
786

@@ -88,7 +16,7 @@ If you prefer your text to be formatted, you may do so in the **HTML** widget. H
8816
...and this is how the Text and HTML widgets look like in the form in QGIS (left) and in the mobile app (right).
8917
![Text and HTML widgets in QGIS and in Mergin Maps mobile app](./qgis-form-text-html.jpg "Text and HTML widgets in QGIS and in Mergin Maps mobile app")
9018

91-
### Using expressions in Text and HTML widgets
19+
## Using expressions in Text and HTML widgets
9220
Expressions and variables can be used both in the Text and the HTML widget.
9321

9422
![QGIS Configure Text Widget Expression Builder](./qgis-text-widget-expression.gif "QGIS Configure Text Widget Expression Builder")
@@ -114,7 +42,7 @@ Clone <MerginMapsProject id="documentation/form_cascade" /> to follow this examp
11442
... and this is how it works during the field survey. `[% "VRP" %]` expression displays the current value of the `Vehicle Registration Plate` field.
11543
![Mergin Maps mobile app text widget with variable](./mobile-text-widget-expression.jpg "Mergin Maps mobile app text widget with variable")
11644

117-
### Using HTML widget to display online images and other online resources
45+
## Using HTML widget to display online images and other online resources
11846
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.
11947

12048
::: tip
@@ -145,7 +73,7 @@ QGIS may not display the preview of the online image if you use QGIS 3.36 or hig
14573
:::
14674

14775

148-
### Using HTML widget to open local files
76+
## Using HTML widget to open local files
14977
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.
15078

15179
::: tip

src/layer/photos/index.md

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
# Capturing Photos
1+
# Photos
22
[[toc]]
33

44
When surveying, you might want to take a photo from your camera or attach an existing photo from the device gallery to your survey feature.
55

6-
To capture and save photos using the <MobileAppNameShort />, the survey layer needs to have a field configured with the [attachment widget](../form-widgets/#attachment).
6+
To capture and save photos using the <MobileAppNameShort />, the survey layer needs to have a field configured with the [**Attachment** widget](#photo-attachment-widget-in-qgis) in QGIS.
77

88
In the <MobileAppNameShort />, this field will provide two options:
99
- **Take a picture** to use your camera app for taking a photos
@@ -12,13 +12,13 @@ In the <MobileAppNameShort />, this field will provide two options:
1212
![Mergin Maps mobile app photo widget](../form-widgets/mobile-form-attachment-photo.jpg "Mergin Maps mobile app photo widget")
1313

1414
:::tip
15-
Do you need to attach multiple pictures to one feature? [How to attach multiple photos to features](../attach-multiple-photos-to-features/) will guide you through the setup.
15+
Do you need to attach multiple pictures to one feature? [How to attach multiple photos to features](#how-to-attach-multiple-photos-to-features) will guide you through the setup.
1616
:::
1717

1818
::: warning
1919
Keep in mind that synchronising photos during the field survey can use up a lot of mobile data - depending on the amount of pictures taken and their size.
2020

21-
To reduce the data usage, you may consider using [selective synchronisation](../../manage/selective_sync/), [resizing pictures automatically](#resizing-pictures-automatically) or following the [offline field survey workflow](../../field/offline-use/#offline-field-survey-workflow).
21+
To reduce the data usage, you may consider using [selective synchronisation](../../manage/selective_sync/), [resizing pictures automatically](../../gis/features/#photo-quality) or following the [offline field survey workflow](../../field/offline-use/#offline-field-survey-workflow).
2222
:::
2323

2424
## Photo attachment widget in QGIS
@@ -27,7 +27,7 @@ To reduce the data usage, you may consider using [selective synchronisation](../
2727
Clone <MerginMapsProject id="documentation/form_setup" /> to follow this example!
2828
:::
2929

30-
In QGIS, the [attachment widget](../form-widgets/#attachment) is used to set up a field to capture photos.
30+
In QGIS, the **Attachment** widget is used to set up a field to capture photos.
3131

3232
To set up the attachment widget:
3333
1. Right-click on a layer, select **Properties** and go to the **Attributes form** tab.
@@ -39,22 +39,11 @@ To set up the attachment widget:
3939
4. **Apply** the changes. Don't forget to save and sync your project!
4040
![QGIS photo attachment widget form](./qgis_forms_photo.jpg "QGIS photo attachment widget form")
4141

42-
Here is an overview of paths that will be stored in various settings of the attachment widget. `path/to/project` represents the project home folder, where the project file is located.
43-
44-
| Default path | Store path as | Value |
45-
|:-------------------------: |:------------: |:----------------------------------: |
46-
| - | Relative to project path | `image.jpg` |
47-
| - | Relative to default path | `image.jpg` |
48-
| `@project_folder` | Relative to project path | `image.jpg` |
49-
| `@project_folder` | Relative to default path | `image.jpg` |
50-
| `@project_home + '/photos'` | Relative to project path | `/photos/image.jpg` |
51-
| `@project_home + '/photos'` | Relative to default path | `image.jpg` |
52-
5342
:::danger Avoid using absolute paths
5443
Using *absolute paths* causes issues when working with your projects on different devices or working in a team: as each device or team member can use different paths, they may be unable to display the attachments.
5544
:::
5645

57-
## How to set up a custom folder for storing photos
46+
### How to set up a custom folder for storing photos
5847
It can be useful to set up a custom folder for photos, e.g. if you want to use [selective synchronisation](../../manage/selective_sync/) or if you simply want to have your data organised.
5948

6049
To set up a custom folder:
@@ -74,6 +63,20 @@ To set up a custom folder:
7463

7564
8. **Apply the changes**. Don't forget to save and sync your project!
7665

66+
### Overview of paths for attachment widget
67+
68+
Here is an overview of paths that can be stored in various settings of the attachment widget.
69+
70+
| Default path | Store path as | Value |
71+
|:-------------------------: |:------------: |:----------------------------------: |
72+
| - | Relative to project path | `image.jpg` |
73+
| - | Relative to default path | `image.jpg` |
74+
| `@project_folder` | Relative to project path | `image.jpg` |
75+
| `@project_folder` | Relative to default path | `image.jpg` |
76+
| `@project_home + '/photos'` | Relative to project path | `/photos/image.jpg` |
77+
| `@project_home + '/photos'` | Relative to default path | `image.jpg` |
78+
79+
7780
## Resizing pictures automatically
7881
Photos that are captured during the field survey or uploaded using <MobileAppName /> can be automatically resized, e.g. to save up storage space. The quality of the photos can be set up in the [<MainPlatformName /> project properties](../../gis/features/#photo-quality) using <QGISPluginName />.
7982

@@ -115,7 +118,7 @@ To see this setup in practice, you can download the following project:
115118

116119
To link multiple photos to a single feature, we need a **unique field** to link following tables:
117120
- Survey layer containing spatial information
118-
- A non-spatial table containing path to the photos (see [how to setup simple photo forms](../photos/))
121+
- A non-spatial table containing path to the photos (see [How to setup simple photo forms](../photos/))
119122

120123
:::danger WARNING
121124
**Do not use the FID field to link these tables**. FIDs can be changed during synchronisation, which can result in having photos linked to the incorrect feature. You can learn more about synchronisation in [Behind Data Synchronisation](../../manage/synchronisation/).
@@ -128,7 +131,7 @@ To set 1:N relation between these tables correctly:
128131
![UUID as default value in Attributes Form](./uuid-default.jpg "UUID as default value in Attributes Form")
129132
3. Create a new text field in the non-spatial table (here: `photos`) that will be used to store the UUID of features from the survey layer (the foreign key), here: `external-pk`.
130133

131-
Now we need to configure a [1-N relation](../one-to-n-relations/):
134+
Now we need to configure a [1-N relation](../relations/):
132135
4. From the main menu, select **Project** > **Properties ...**
133136
5. In the **Relations** tab, select **Add Relation**
134137
![Add relation in Project Properties](./qgis_relation_tab.jpg "Add relation in Project Properties")

src/layer/relations/index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Relations
1+
# Relationships
22

33
:::tip Example project available
44
You can clone these projects to take a closer look at 1-N relations:

0 commit comments

Comments
 (0)