Skip to content

Commit 2ef4a9c

Browse files
committed
docs: remove json-editor plugin from the docs and add key-value renderer section in json-form plugin
AdminForth/1843/we-got-confused-and-spend-some
1 parent 1369459 commit 2ef4a9c

4 files changed

Lines changed: 22 additions & 67 deletions

File tree

adminforth/documentation/docs/tutorial/09-Plugins/28-json-editor.md

Lines changed: 0 additions & 65 deletions
This file was deleted.

adminforth/documentation/docs/tutorial/09-Plugins/29-json-form.md renamed to adminforth/documentation/docs/tutorial/09-Plugins/28-json-form.md

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ pnpm add @adminforth/json-form --save
2020

2121
The plugin works **only with `json` columns**. If the target column is not of type `json`, the plugin throws during config validation.
2222

23-
First update schema:
23+
First, update the schema:
2424

2525
```title="./schema.prisma"
2626
model apartments {
@@ -29,7 +29,7 @@ model apartments {
2929
config Json?
3030
}
3131
```
32-
and make migration:
32+
and make a migration:
3333

3434
```bash
3535
pnpm makemigration --name add-apartment-config; pnpm migrate:local
@@ -132,3 +132,23 @@ export default {
132132

133133
The same form is rendered in both the create and edit views for the `config` field.
134134

135+
## Key-value renderer
136+
137+
Since using JSON as key-value storage is a popular use case, the JSON Form plugin provides a custom key-value editor:
138+
139+
```js title="schema example"
140+
schema: {
141+
"title": "Specifications",
142+
"type": "object",
143+
"additionalProperties": {
144+
"type": "string"
145+
}
146+
}
147+
```
148+
149+
![Key-value editor](json-form-key-value-editor.png)
150+
151+
Any object that declares no `properties` and does not set `additionalProperties: false` is rendered this way by default, so no extra keyword is needed to opt in. Rows are added inline, without a popup: the new key starts empty and gets the focus, the key itself is applied when the input loses focus or on `Enter`, and the trash button removes the entry right away. Renaming a key to one that already exists is refused with an inline message.
152+
153+
The value cell holds the regular editor for whatever `additionalProperties` describes, so values are not limited to strings — nested objects and arrays work too, and keep their own formatting and validation rules.
154+
16.2 KB
Loading
Binary file not shown.

0 commit comments

Comments
 (0)