fullstackpe/micro-form 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

fullstackpe/micro-form

Composer 安装命令:

composer require fullstackpe/micro-form

包简介

Form builder

README 文档

README

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. After that run

composer require fullstackpe/micro-form

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

{
    "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

$json = '[
    {
        "tag": "input",
        "type": "text",
        "name": "username",
        "class": "form-control"
    }
]';

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

output

<input type="text" name="username" class="form-control">

Textarea

<?php

$json = '[
    {
        "tag": "textarea",
        "id": "story",
        "name": "story",
        "rows": "5",
        "cols": "33",
        "value": "It was a dark and stormy night..."
    }
]';

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

output

<textarea id="story" name="story" rows="5" cols="33">
It was a dark and stormy night...
</textarea>

Select

<?php

$json = '[
    {
        "tag": "select",
        "name": "pets",
        "id": "pet-select",
        "value": [
            {
                "tag": "option",
                "label": "--Please choose an option--",
                "value": ""
            },
            {
                "tag": "option",
                "label": "Dog",
                "value": "dog"
            },
            {
                "tag": "option",
                "label": "Cat",
                "value": "cat"
            }
        ]
    }
]';

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

output

<select name="pets" id="pet-select">
    <option value="">--Please choose an option--</option>
    <option value="dog">Dog</option>
    <option value="cat">Cat</option>
</select>

Contribution

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

License

This library is released under the MIT License.

统计信息

  • 总下载量: 540
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 15
  • 点击次数: 2
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 15
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2018-03-02

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固