Skip to content

Commit

Permalink
chore: long list tip
Browse files Browse the repository at this point in the history
  • Loading branch information
danielo515 committed Dec 16, 2024
1 parent c1df8e4 commit 570377a
Show file tree
Hide file tree
Showing 4 changed files with 48 additions and 0 deletions.
22 changes: 22 additions & 0 deletions EXAMPLE_VAULT/.obsidian/plugins/modal-form/data.json
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,28 @@
}
],
"version": "1"
},
{
"title": "Long list tip example",
"name": "long-list",
"version": "1",
"fields": [
{
"name": "chore",
"label": "Chores",
"description": "Pick a chore to do",
"input": {
"type": "dataview",
"allowUnknownValues": false,
"hidden": false,
"options": [],
"source": "notes",
"query": "[\n 'Wash the dishes',\n 'Take out the trash',\n 'Do the laundry',\n 'Mow the lawn',\n 'Feed the cat',\n 'Feed the dog',\n 'Feed the fish',\n 'Feed the birds',\n 'Feed the turtles',\n 'Feed the rabbits',\n 'Feed the turtles',]",
"multi_select_options": []
},
"isRequired": false
}
]
}
]
}
26 changes: 26 additions & 0 deletions docs/long-list-tip.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
# TIP: How to put a long list of values in a select without having to type them one by one

When you already have a long list of values that you want in a select input, instead of putting them one by one in the fixed list, you can use the `dataview` input type and just return the values as an array in the dataview query.

For example, you can put the following in a select input with `dataview` as the source:

```ts
return [
'Wash the dishes',
'Take out the trash',
'Do the laundry',
'Mow the lawn',
'Feed the cat',
'Feed the dog',
'Feed the fish',
'Feed the birds',
'Feed the turtles',
'Feed the rabbits',
'Feed the turtles',]
```

And the result will be:
![demo modal](long-list-tip.png)

Here is an screenshot of how it looks in the form builder:
![demo modal](./media/long-list-builder.png)
Binary file added docs/long-list-tip.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/media/long-list-builder.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 570377a

Please sign in to comment.