Skip to content

Commit

Permalink
docs: FormResult methods
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Oct 26, 2023
1 parent 15fe555 commit f8a2b29
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 1 deletion.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,8 @@ Here you have an example screenshot of how it should look like:

### FormResult Methods

The `FormResult` object returned by the `openForm` method has several methods that can be used to process the form data. Here is a brief description of each method:
When you open a form, you get back a `FormResult` object. This object contains the data of the form and some methods to help you process it.
This `FormResult` object returned by the `openForm` method has several methods that can be used to process the form data. Here is a brief description of each method:

#### asFrontmatterString()

Expand All @@ -136,6 +137,9 @@ tR += result.asString('{{Name}} is {{age}} years old and his/her favorite food i
-%>
```
#### Advanced usage
For more advanced usage of the `FormResult` methods please refer to the specific documentation of FormResult [here](docs/managing-results.md)
### Define a form
Expand Down
46 changes: 46 additions & 0 deletions src/docs/magaing-results.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Managing Results

The `FormResult` class provides methods for managing form results.

## `asFrontmatterString(options?: unknown): string`

Transforms the current data into a frontmatter string, which is expected to be enclosed in `---` when used in a markdown file. This method does not add the enclosing `---` to the string, so you can put it anywhere inside the frontmatter.

### Parameters

- `options` (optional): An options object describing what options to pick or omit.

- `pick` (optional): An array of key names to pick from the data.
- `omit` (optional): An array of key names to omit from the data.

### Returns

- `string`: The data formatted as a frontmatter string.

### Example

```typescript
const result = await form.openForm('my-form')
tR += result.asFrontmatterString({ pick: ['title'] });
```

## `asDataviewProperties(options?: unknown): string`

Returns the current data as a block of dataview properties.

### Parameters

- `options` (optional): An options object describing what options to pick or omit.

- `pick` (optional): An array of key names to pick from the data.
- `omit` (optional): An array of key names to omit from the data.

### Returns

- `string`: The data formatted as a block of dataview properties.

### Example

```typescript
const result = await form.openForm('my-form')
tR += result.asDataviewProperties({ pick: ['title'] });`

0 comments on commit f8a2b29

Please sign in to comment.