dmstr/yii2-json-editor

Yii2 wrapper for "json-editor/json-editor" (is a fork of "jdorn/json-editor")

Installs: 22 194

Dependents: 4

Suggesters: 0

Security: 0

Stars: 6

Watchers: 6

Forks: 7

Open Issues: 0

Type:yii2-extension

1.3.1 2021-06-30 11:20 UTC

README

Yii2 wrapper for "json-editor/json-editor" (fork of "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 for information about recommended composer packages.

Changelog

1.3

  • updated json-editor to ^2.3.5 (affects custom editor extends usage, see commit)

1.2

See git log

Usage

$example_schema = [
    'title' => 'Example JSON form',
    'type' => 'object',
    'properties' => [
        'name' => [
            'title' => 'Full Name',
            'type' => 'string',
            'minLength' => 5
        ],
        'date' => [
            'title' => 'Date',
            'type' => 'string',
            'format' => 'date',
        ],
    ],
];
$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,
    ],
]);