PHP Classes

PHP JSON Form Builder: Generate a HTML form definition in JSON format

Recommend this page to a friend!
  Info   View files Example   Screenshots Screenshots   View files View files (5)   DownloadInstall with Composer Download .zip   Reputation   Support forum (2)   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2020-05-17 (15 hours ago) RSS 2.0 feedNot enough user ratingsTotal: 266 This week: 152All time: 7,611 This week: 1Up
Version License PHP version Categories
json-form-generator 1.3MIT/X Consortium ...5HTML, PHP 5
Description Author

This class can generate a HTML form definition in JSON format.

It takes as parameter the path of a JSON file and parses it to extract the definition of the form options as well the options of all the inputs contained in the form.

The class generates HTML for the form and its inputs.

Innovation Award
PHP Programming Innovation award nominee
April 2020
Nominee
Vote
Many Web applications need to render forms to get information from their users.

This class provides an easy way to generate HTML forms from files with definitions read from a file in JSON format.

Manuel Lemos
  Performance   Level  
Name: Arash Soleimani <contact>
Classes: 4 packages by
Country: Iran Iran
Innovation award
Innovation award
Nominee: 2x

 

Details

JSON Form Generator

LeoMoon JFG generates HTML form tags from JSON file/input. JFG supports all types and attributes of form tags.

Why JSON?

Companies change their software every couple of years. If they have too many pages and forms, they need to redesign the whole thing again. But when you are using JSON format, you don't have to worry about redesigning everything. You just write a new JSON render engine in a new programming language or framework. Here is an example:

Documentation

Usage

  require_once('form.class.php');
  $form = new Form(['file'=>'./example_form.json']);
  $form->show();

Sample JSON file

{
    "name": "formName",
    "title": "Registration form",
    "description": "simple JFG example.",
    "method": "post",
    "action": "http://leomoon.com",
    "properties": {
      "firstName": {
        "type": "input",
        "title": "First name",
        "name":"firstName",
        "value": "test",
        "required": true,
        "onChange":"console.log(this.value)"
      },
      "lastName": {
        "type": "input",
        "title": "Last name",
        "name":"lastName",
        "disabled": true
      },
      "age": {
        "type": "number",
        "title": "Age",
        "name":"age"
      },
      "bio": {
        "type": "input",
        "title": "Bio",
        "name":"bio",
        "placeholder":"Biography"
      },
      "password": {
        "type": "password",
        "title": "Password",
        "name":"password",
        "min": 3
      },
      "language": {
        "type": "select",
        "title": "Language",
        "name":"lang",
        "options":
            {"en":"English",
            "fa":"Farsi",
            "de":"German"
            }
      },
      "submit": {
        "type": "submit",
        "title": "Save Form",
        "name":"submit"
      }
    }
  }
Screenshots  
  • json-form-generator-sample.jpg
  Files folder image Files  
File Role Description
Accessible without login Plain text file example.php Example Example script
Accessible without login Plain text file example_form.json Data Auxiliary data
Plain text file form.class.php Class Class source
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 83%
Total:266
This week:152
All time:7,611
This week:1Up

For more information send a message to info at phpclasses dot org.