Skip to content

Commit

Permalink
Merge pull request #132 from danielo515/danielo515-patch-1
Browse files Browse the repository at this point in the history
Update advanced-examples.md
  • Loading branch information
danielo515 authored Nov 16, 2023
2 parents 8840b95 + d7bf3cd commit 61cf49c
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions docs/advanced-examples.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,20 @@ In this section of the docs you will find some advanced usage examples of modal-
## Nesting form calls

## Modifying frontmatter with a form

If you want to modify the content of a notes frontmatter with one of your existing forms, put the following
snippet in a templater template, substituting the name of your form:

```js
<%*
const modalForm = app.plugins.plugins.modalforms.api;
app.fileManager.processFrontMatter(tp.config.target_file,
async (frontmatter) => {
const result = await modalForm.openForm('example-form', { values: {...frontmatter}});
Object.assign(frontmatter, result.getData());
})}, 200)
%>
```

The values the form understand and that are pressent in the frontmatter, will be populated with the values on the frontmatter.
Then, when you submit the form, the new values will overwrite the old ones, leaving the rest untouched.

0 comments on commit 61cf49c

Please sign in to comment.