Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/israeljunior/json-to-form

A lightweight script to generate forms from objects or JSON files.
https://github.com/israeljunior/json-to-form

form javascript json vanilla-js

Last synced: 4 days ago
JSON representation

A lightweight script to generate forms from objects or JSON files.

Awesome Lists containing this project

README

        

# JsonToForm
A lightweight script to generate forms from objects or JSON files.


## Getting Started
Compiled and production-ready code can be found in the `dist` directory. The `src` directory contains development code.

### 1. Include JsonToForm on your site
You can [download the files directly from GitHub](https://github.com/israeljunior/json-to-form/archive/master.zip).

```html

```

### 2. Add the markup to your HTML
Needed only a container for the form.

```html


```

### 3. Initialize JsonToForm
In the footer of your page, after the content, initialize JsonToForm by passing in an object or JSON path, and the selector for the container.

```html

var form1 = new JsonToForm({
data: './src/data.json',
container: '#form1'
})

// OR

var form1 = new JsonToForm({
data: {
options: {
action: 'submit.php'
},
fields: [
{
name: 'name',
placeholder: 'Enter your name'
},
{
name: 'email',
placeholder: 'Enter a valid email address',
type: 'email'
},
{
name: 'options',
type: 'checkbox',
data: [
{title: 'aaa'},
{title: 'bbb'},
{title: 'ccc'},
]
}
]
},
container: '#form1'
})

```

## License
The code is available under the [MIT License](LICENSE.txt).