Ecosyste.ms: Awesome

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

Awesome Lists | Featured Topics | Projects

https://github.com/marcomilon/micro-form

A tool to generate an HTML Form from a JSON file
https://github.com/marcomilon/micro-form

composer form-builder form-generator html-form html-inputs json json-form json-form-php jsonforms php

Last synced: 2 days ago
JSON representation

A tool to generate an HTML Form from a JSON file

Awesome Lists containing this project

README

        

# micro-form

Micro-form is a library to translate any datasource into into html form elements. Only Json Objects can be use as datasources.

### Installation

First you need to install Composer. You may do so by following the instructions at [getcomposer.org](https://getcomposer.org/download/). After that run

> composer require fullstackpe/micro-form

If you prefer you can create a composer.json in your project folder.

```json
{
"require": {
"fullstackpe/micro-form": "^3.0"
}
}
```

### How it works?

Create a `jsform` object.

```
use micro\FormFactory;
$jsonForm = FormFactory::jsonForm();
echo $jsonForm->render($json);
```

then call render to get the form elements. The render method accepts a Json Object.

**Examples**

**Input**

```php
render($json);
```

*output*

```html

```

**Textarea**

```php
render($json);
```

*output*

```html

It was a dark and stormy night...

```

**Select**

```php
render($json);
```

*output*

```html

--Please choose an option--
Dog
Cat

```

### Contribution

Feel free to contribute! Just create a new issue or a new pull request.

### License

This library is released under the MIT License.