# JSON Field for Siberfx Crud 6


This package provides a ```json``` field type for the [Siberfx CRUD for Laravel](https://siberfx.com/) administration panel. The field allows the admin to manually edit the contents of a column where a JSON is stored, using the JS plugin. That means they'll have:
- multiple modes of viewing the JSON (code, tree, form)
- syntax highlighting
- indented code
- color picker
- searching
- undo & redo
- etc.

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.

## Screenshots

![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)

Backpack v6 with Tabler, light and dark modes
![https://github.com/ziming/json-field-for-backpack/assets/82019078/bdd36562-d46c-4966-ad02-4e765675eae4](https://github.com/ziming/json-field-for-backpack/assets/82019078/bdd36562-d46c-4966-ad02-4e765675eae4)

## Installation

Via Composer

``` bash
composer require ziming/json-field-for-backpack
```

## Usage

Inside your custom CrudController:

```php
$this->crud->addField([
    'name'  => 'column_name',
    'type'  => 'json',
    
    // OPTIONAL
    
    // Which modes should the JsonEditor JS plugin allow?
    // Please note that the first mode in the array will be used as the default mode.
    'modes' => ['form', 'tree', 'code'],
     
    // Default value, if needed. If there is an actual value in the json column, 
    // it will do an array_merge_recursive(), with the json column values 
    // replacing the ones with the same keys.
    'default' => [],
]);
```
