Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update advanced-examples.md #132

Merged
merged 1 commit into from
Nov 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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.