Skip to content

Commit d7870e6

Browse files
authored
rephrase README and add screenshot (#3)
1 parent 6a88bb4 commit d7870e6

File tree

1 file changed

+26
-12
lines changed

1 file changed

+26
-12
lines changed

readme.md

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,23 @@
1-
# Json Field for Backpack 4
1+
# JSON Field for Backpack 4
22

33
[![Latest Version on Packagist][ico-version]][link-packagist]
44
[![Total Downloads][ico-downloads]][link-downloads]
55

6-
This package provides a ```json``` field type for the [Backpack for Laravel](https://backpackforlaravel.com/) administration panel.
6+
This package provides a ```json``` field type for the [Backpack for Laravel](https://backpackforlaravel.com/) administration panel. The field allows the admin to manually edit the contents of a column where a JSON is stored, using the [`josdejong/jsoneditor`](https://github.com/josdejong/jsoneditor) JS plugin. That means they'll have:
7+
- multiple modes of viewing the JSON (code, tree, form)
8+
- syntax highlighting
9+
- indented code
10+
- color picker
11+
- searching
12+
- undo & redo
13+
- etc.
14+
15+
Of course, this field should only be used when the admin is savvy enough to know what JSON is. Otherwise they can completely mess up the structure/format of the JSON stored in the database column.
716

817
## Screenshots
918

19+
![https://user-images.githubusercontent.com/1032474/97699650-e2e92b80-1a80-11eb-8320-3ac35e8a59a1.gif](https://user-images.githubusercontent.com/1032474/97699650-e2e92b80-1a80-11eb-8320-3ac35e8a59a1.gif)
20+
1021
## Installation
1122

1223
Via Composer
@@ -21,17 +32,20 @@ Inside your custom CrudController:
2132

2233
```php
2334
$this->crud->addField([
24-
'name' => 'column_name',
25-
'type' => 'json_editor',
26-
'modes' => ['form', 'tree', 'code'], // Optional. 1st item will be the default mode
27-
28-
// Optional. default json value in php array style.
29-
30-
// If there is an actual value in the json column, it will do an
31-
// array_merge_recursive. With the json column values replacing the
32-
// ones with the same keys
33-
'default' => [], // Optional. default json value in php array style.
35+
'name' => 'column_name',
36+
'type' => 'json',
3437
'view_namespace' => 'json-field-for-backpack::fields',
38+
39+
// OPTIONAL
40+
41+
// Which modes should the JsonEditor JS plugin allow?
42+
// Please note that the first mode in the array will be used as the default mode.
43+
'modes' => ['form', 'tree', 'code'],
44+
45+
// Default value, if needed. If there is an actual value in the json column,
46+
// it will do an array_merge_recursive(), with the json column values
47+
// replacing the ones with the same keys.
48+
'default' => [],
3549
]);
3650
```
3751

0 commit comments

Comments
 (0)