Skip to content

Commit 4034db9

Browse files
authored
chore: updates documentation on how to use Web Forms (#357)
1 parent eb050c7 commit 4034db9

File tree

1 file changed

+34
-6
lines changed

1 file changed

+34
-6
lines changed

packages/web-forms/README.md

Lines changed: 34 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,21 +7,49 @@ This package is a Vue component library that uses [`@getodk/xforms-engine`](../x
77
To use this library in a Vue.js application:
88

99
1. Import `@getodk/web-forms` as a dependency in the application
10-
2. Install the exported plugin by adding app.use(WebFormsPlugin) in entry component (usually App.vue)
10+
2. Install the exported plugin by adding `app.use(WebFormsPlugin)` in entry component (usually App.vue)
1111
3. Add the exported component anywhere in the application:
1212

1313
```html
14-
<OdkWebForm :form-xml="formVersionXml.data" @submit="handleSubmit" />
14+
<OdkWebForm
15+
:form-xml="formXml"
16+
:fetch-form-attachment="fetchAttachment"
17+
:missing-resource-behavior="missingBehavior"
18+
:submission-max-size="5242880" <!-- 5MB -->
19+
:edit-instance="editOptions"
20+
@submit="handleSubmit"
21+
@submit-chunked="handleChunkedSubmit"
22+
/>
1523
```
1624

17-
**Plugin:**
25+
### Plugin
1826

1927
The plugin is there to initialize PrimeVue, currently it exposes no options. In the future, configuration options may be added to the plugin.
2028

21-
**Props and Events:**
29+
```js
30+
import { WebFormsPlugin } from '@getodk/web-forms';
31+
app.use(WebFormsPlugin);
32+
```
33+
34+
### Props (`OdkWebFormsProps`)
35+
36+
The `<OdkWebForm>` component accepts the following props:
37+
38+
- `formXml` (`string`, required): The XML of the ODK XForm to be rendered
39+
- `fetchFormAttachment` (`FetchFormAttachment`, required): Function to fetch form attachments
40+
- `missingResourceBehavior` (`MissingResourceBehavior`, optional): Defines behavior when resources are missing
41+
- `submissionMaxSize` (`number`, optional): Maximum size for chunked submissions. Required when subscribing to `submitChunked` event
42+
- `editInstance` (`EditInstanceOptions`, optional): Options to resolve and load instance and attachment resources for editing
43+
44+
### Events (`OdkWebFormEmits`)
45+
46+
The component emits the following events:
2247

23-
- `form-xml`: the XML of the ODK XForm to be rendered.
24-
- `submit`: it is raised when user pressed "Send" button on the Form.
48+
- `submit`: Emitted when the user presses the "Send" button on a valid form
49+
- Payload: ([submissionPayload: MonolithicInstancePayload, callback: HostSubmissionResultCallback])
50+
- `submitChunked`: Emitted for chunked submissions when the form is valid
51+
- Payload: ([submissionPayload: ChunkedInstancePayload, callback: HostSubmissionResultCallback])
52+
- Note: Requires `submissionMaxSize` prop to be set
2553

2654
### What if I don't use Vue?
2755

0 commit comments

Comments
 (0)