https://github.com/dmstr/yii2-json-editor
Yii2 wrapper for "json-editor/json-editor" (is a fork of "jdorn/json-editor").
https://github.com/dmstr/yii2-json-editor
Last synced: about 2 months ago
JSON representation
Yii2 wrapper for "json-editor/json-editor" (is a fork of "jdorn/json-editor").
- Host: GitHub
- URL: https://github.com/dmstr/yii2-json-editor
- Owner: dmstr
- License: bsd-2-clause
- Created: 2018-02-26T17:00:47.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2024-09-25T10:42:16.000Z (over 1 year ago)
- Last Synced: 2025-05-12T07:20:02.066Z (about 1 year ago)
- Language: PHP
- Size: 478 KB
- Stars: 9
- Watchers: 7
- Forks: 9
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yii2-json-editor
Yii2 wrapper for "[json-editor/json-editor](https://github.com/json-editor/json-editor)" (fork of "[jdorn/json-editor](https://github.com/jdorn/json-editor)").
## Configuration
If you want to use additional tested plugins, such as *CKEditor*, *selectize* or *filefly* you can include the following lines in your view
```
JsonEditorPluginsAsset::register($this);
```
See the `suggest` section of [`composer.json`](https://github.com/dmstr/yii2-json-editor/blob/master/composer.json) for information about recommended composer packages.
## Changelog
### 1.3
- updated `json-editor` to `^2.3.5` (affects custom editor `extends` usage, [see commit](https://github.com/dmstr/yii2-json-editor/commit/731dd3dce28887fabd536f5c5ba37218ba243c73))
### 1.2
See `git log`
## Usage
```php
$example_schema = [
'title' => 'Example JSON form',
'type' => 'object',
'properties' => [
'name' => [
'title' => 'Full Name',
'type' => 'string',
'minLength' => 5
],
'date' => [
'title' => 'Date',
'type' => 'string',
'format' => 'date',
],
],
];
```
```php
$form->field($model, 'example_field')->widget(JsonEditorWidget::className(), [
'schema' => $example_schema,
'clientOptions' => [
'theme' => 'bootstrap3',
'disable_collapse' => true,
'disable_edit_json' => true,
'disable_properties' => true,
'no_additional_properties' => true,
],
]);
```
## Plugin Bundles
This packages contains optional asset bundles for specialized plugings that can be rgistered when activated in the
configuration array.
- CKEditorAsset (active per default for backward compatibility reasons)
- JoditAsset
- SceditorAsset
- SimpleMDEAsset
```php
$form->field($model, 'example_field')->widget(JsonEditorWidget::className(), [
'schema' => $example_schema,
'registerCKEditorAsset' => true, // CKEditorAsset will be registered (default true)
'registerJoditAsset' => true, // JoditAsset will be registered (default false)
'registerSceditorAsset' => true, // SceditorAsset will be registered (default false)
'registerSimpleMDEAsset' => true, // SimpleMDEAsset will be registered (default false)
'clientOptions' => [
'theme' => 'bootstrap3',
]
]);
```