• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

brutusin/json-forms: JSON Schema to HTML form generator, supporting dynamic subs ...

原作者: [db:作者] 来自: 网络 收藏 邀请

开源软件名称:

brutusin/json-forms

开源软件地址:

https://github.com/brutusin/json-forms

开源编程语言:

JavaScript 97.1%

开源软件介绍:

json-forms

bower version Build Status

org.brutusin:json-forms is a javascript library that generates HTML forms from JSON Schemas.

Status

I am currently not having time to maintain this project, so first of all my apologies if some issues have been unresponded. Branch v2 contains a completely new rearchitecture of the project, that I started several months ago but left unfinished. If someone is interested in continuing my work I will be happy to guide them


Table of Contents:

Features

  • Dynamic schemas support
  • Extensible and customizable
  • No external libraries needed
  • Validation
  • Multiple forms per document supported

Usage

Include the main library dependencies:

<link rel="stylesheet" href='dist/css/brutusin-json-forms.min.css'/>
<script src="dist/js/brutusin-json-forms.min.js"></script>

Optionally, include the bootstrap extension (requires bootstrap):

<script src="dist/js/brutusin-json-forms-bootstrap.min.js"></script>

Create the javascript BrutusinForms instance, schema being a javascript object representing the schema structure:

var schema = {"type": "boolean"}
var BrutusinForms = brutusin["json-forms"];
var bf = BrutusinForms.create(schema);

And finally render the form inside a container with optional preloaded JSON initial data, data:

var container = document.getElementById('container');
bf.render(container, data);

Demo

demo http://brutusin.org/json-forms/

Dynamic schemas

This library supports dynamic schemas, that is, subschemas that can change depending on the value of other parts of the data.

This lets creating dynamic forms that vary their shape depending on the values entered by the user. This is extremely useful for big autogenerated schemas, that aggregates lots of subschemas and have functional bindings, given that it allows to show the user a simpler, non-error-prone form, also avoiding asking for unneeded data.

Dynamic schemas are built upon two main blocks:

dependsOn schema extension

Dynamic schema resolution

API

Static members:

Member Description
BrutusinForms.create(schema) BrutusinForms factory method
BrutusinForms.addDecorator(f(htmlElement, schema)) Register a callback function to be notified after an HTML element has been rendered (passed as parameter). See brutusin-json-forms-bootstrap.js for an example of bootstrap decorator.
BrutusinForms.postRender(instance) Callback function to be notified after a BrutusinForms instance has been rendered (passed as parameter)
BrutusinForms.instances Array containing all the BrutusinForms instances created in the document by the factory method.

Instance members:

Member Description
bf.render(container, data) Renders the form inside the the container, with the specified data preloaded
bf.validate() Returns true if the input data entered by the user passes validation
bf.getData() Returns the javascript object with the data entered by the user
bf.schemaResolver(schemaIdArray, data) Schema resolver for dynamic schemas

CDN

http://www.jsdelivr.com/projects/brutusin.json-forms

Support bugs and requests

https://github.com/brutusin/json-forms/issues

Authors

Contributions are always welcome and greatly appreciated!

License

Apache License, Version 2.0




鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap