Add checkbox example to input

This commit is contained in:
Luke committed 2022-05-02 14:00:05 +02:00
1 parent b1b1ed6137
commit 340c3a7375
1 file changed
+26 -2
+26 -2
View File
@@ -2,6 +2,9 @@
title: Input Dialog title: Input Dialog
--- ---
import Tabs from '@theme/Tabs';
import TabItem from '@theme/TabItem';
The input dialog window allows you to take data from the user The input dialog window allows you to take data from the user
by setting input fields. by setting input fields.
@@ -26,9 +29,16 @@ The input rows will always return a string, if you want a row to be of
number data type, you can use the `tonumber` function to convert it to number data type, you can use the `tonumber` function to convert it to
a number instead. a number instead.
If a user left an input field empty it will return `nil` If a user left an input field empty it will return `nil`.
You can also add checkboxes that will return `true` if checked and `nil` if unchecked.
Look at the *Advanced* example for it's usage.
**Example:** **Example:**
<Tabs>
<TabItem value="basic" label="Basic">
```lua ```lua
local input = lib.inputDialog('Police locker', {'Locker number', 'Locker passcode'}) local input = lib.inputDialog('Police locker', {'Locker number', 'Locker passcode'})
@@ -39,5 +49,19 @@ if input then
print(lockerNumber, lockerPasscode) print(lockerNumber, lockerPasscode)
end end
``` ```
![Example image](https://i.imgur.com/RvFFZqv.png)
</TabItem>
<TabItem value='advanced' label='Advanced'>
![Example image](https://i.imgur.com/RvFFZqv.png) ```lua
local input = lib.inputDialog('Police locker', {
{ type = "input", label = "Locker number" },
{ type = "checkbox", label = "Some checkbox" },
{ type = "input", label = "Locker PIN" },
{ type = "checkbox", label = "Some other checkbox" },
})
print(json.encode(input, {indent=true}))
```
![Example image](https://i.imgur.com/2NM6yDQ.png)
</TabItem>
</Tabs>