dmstr/yii2-json-editor

为"json-editor/json-editor"提供的Yii2包装器(是"jdorn/json-editor"的分支)

安装数: 49 002

依赖者: 5

推荐者: 0

安全性: 0

星标: 8

关注者: 8

分支: 9

开放问题: 1

类型:yii2-extension

1.5.0 2024-05-15 08:10 UTC

README

为"json-editor/json-editor"提供的Yii2包装器(是"jdorn/json-editor"的分支)。

配置

如果您想使用额外的经过测试的插件,例如CKEditorselectizefilefly,您可以在视图中包含以下行

JsonEditorPluginsAsset::register($this);

有关推荐Composer包的信息,请参阅composer.json中的suggest部分。

变更日志

1.3

  • 已更新json-editor^2.3.5(影响自定义编辑器的extends使用,查看提交

1.2

查看git log

使用方法

$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,
    ],
]);

插件包

此包包含可选的资产包,这些资产包可以在配置数组中激活时注册。

  • CKEditorAsset(默认激活以保持向后兼容性原因)
  • JoditAsset
  • SceditorAsset
  • SimpleMDEAsset
$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',
    ]
]);