dimensi0n/simple-form 问题修复 & 功能扩展

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

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

dimensi0n/simple-form

Composer 安装命令:

composer require dimensi0n/simple-form

包简介

Simple Form generator

README 文档

README

PHP Composer

Provides a simple form generator and a data validator

How to use it ?

Install it :

composer require dimensi0n/simple-form

This :

$form = new \SimpleForm\Form('Login');
        $form->addInput('email', 'email', 'Email address') // name, type, label
		   ->addInput('password', 'password', 'Mot de passe') // name, type, label
           ->addSubmit('Submit'); // content

echo $form->renderHTML;

Will render this :

<form action="" method="POST">
    <label for="email">Email Address</label>
    <input type="email" name="email" class="form-control" id="email"/>
    <label for="password">Password</label>
    <input type="password" name="password" class="form-control" id="password"/>
    <button type="submit" class="btn btn-primary" id="Submit">Submit</button>
</form>

In order to validate the form and get its value you just have to write this :

$values = $form->getValues($_POST); // check if all fields are filled, also applies trim(), stripslashes() and htmlspecialchars()

if (isset($values['empty'])) {
    foreach($values['empty'] as $empty_value) {
        echo $empty_value.' is empty'; // 'Name of the empty field' is empty
    }
} else {
    echo 'Email : '.$values['email'];
    echo 'Password : '.$values['password'];
}

Custom Rendering

Example with bootstrap :

$form = new \SimpleForm\Form('Login');
        $form->addInput('email', 'email', 'Email address') // name, type, label
		   ->addInput('password', 'password', 'Mot de passe') // name, type, label
           ->addSubmit('Submit'); // content

<div class="container">
    <?= $form.formStart() ?>
    <div class="form-group">
        <?= $form.formInput('email') ?> // Will render label and input
    </div>
    <div class="form-group">
        <?= $form.formInput('password') ?> // Will render label and input
    </div>
    <?= $form.formEnd() ?>
</div>

For further information check the API docs : https://dimensi0n.github.io/simple-form/api

统计信息

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

GitHub 信息

  • Stars: 1
  • Watchers: 1
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-03-31

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固