rwitchell/gump-form-builder 问题修复 & 功能扩展

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

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

rwitchell/gump-form-builder

最新稳定版本:1.0.2

Composer 安装命令:

composer require rwitchell/gump-form-builder

包简介

A fast, extensible & stand-alone PHP form builder class.

README 文档

README

A PHP class to help generate a web form, based on an input of text rules separated with pipes. Based on GUMP (https://github.com/Wixel/GUMP), by Sean Nieuwoudt (http://twitter.com/SeanNieuwoudt)

Can be used to pull an entity directly from the database, and present table columns as inputs. You can then validate those inputs, and pass back into the database.

Script was built to handle 30-150 form elements that needed to have various rules. When the form is submitted, rules are then passed into GUMP for input value validation.

Getting Started

How to Use (extended):

// build array
$input_rules = array(
    'id'          => 'nodisplay'
    ,'title'      => 'select|options,array-titleOptions'
    ,'firstName'  => 'text|max_len,4'
    ,'lastName'   => 'text|after,(Family name)'
    ,'dob'	      => 'datetime|id,dob_datePicker'
    );

$arrayOptions  = array(
    'titleOptions' => array(
        'Mr'=>'Mr'
        ,'Mrs'=>'Mrs'
        ,'Ms'=>'Ms'
        ,'Miss'=>'Miss'
        )
    );

$input_javascript = array(
    //http://trentrichardson.com/examples/timepicker/
    "$('#dob_datePicker').datetimepicker({
                    dateFormat: 'yy-mm-dd'
                    ,timeFormat: 'HH:mm z'
                    ,minuteGrid: 15
                    ,numberOfMonths: 1
                    ,minDate: -90
                    ,maxDate: 1
                    ,addSliderAccess: true
                    ,sliderAccessArgs: { touchonly: false }
                }); \n" 
    );

$inputColumns = array('id', 'title', 'firstName', 'lastName', 'dob', 'phone' );
$formBuilder = new \GumpFormBuilder\GumpFormBuilder(); // rules controller
	
if( isset($request->get->view) ) {
    $formBuilder->form_viewOnly( array('firstName', 'lastName') ); // Allows you to rearrange your view.
}


$formBuilder->form_rules($input_rules);
$formBuilder->form_rules_options($arrayOptions);

$inputArray = $formBuilder->run($inputColumns); // runs through all the fields and creates the HTML
$otherInputArray = $formBuilder->getOtherInputs(); 			// places non-prioritised inputs here
        
$html .= <<<HEREDOC
        <form name="registerForm" id="registerForm" action="register.php" method="post" enctype="application/x-www-form-urlencoded">
            <fieldset>
                {$inputArray}
                <button type='submit' name='submit' value="Register">Register</button>
            </fieldset>
            
            <fieldset>
                {$otherInputArray} 
            </fieldset>
        </form>
HEREDOC;
            
$html .= $formBuilder->outputJavaScript($input_javascript);
echo $html;

Available Elements

Input form options available:

  • text (default if none is entered)
  • select dropdown
  • options array of key-value pairs
  • checkbox
  • radio
  • file
  • button
  • hidden
  • password
  • datetime (via jquery / javascript)
  • nodisplay will not create the input
  • max_len Place an input restriction on the number of characters that can be entered into a text input
  • id places a value in the id selector for the input
  • after generated text directly to the right of the input
  • readonly makes the input readonly
  • yesno creates a simply radio option

Input validator options available:
(All GUMP options currently available)

  • required
  • max_len

How to contribute

TODO:

  • finish off elements
  • build array to sort elements

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2014-11-25

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固