PHPackages                             rwitchell/gump-form-builder - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. rwitchell/gump-form-builder

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rwitchell/gump-form-builder
===========================

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

1.0.2(11y ago)647MITPHP

Since Mar 19Pushed 11y ago1 watchersCompare

[ Source](https://github.com/rwitchell/gump-form-builder)[ Packagist](https://packagist.org/packages/rwitchell/gump-form-builder)[ Docs](https://github.com/rwitchell/GUMPFormBuilder)[ RSS](/packages/rwitchell-gump-form-builder/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependenciesVersions (2)Used By (0)

What is it?
===========

[](#what-is-it)

A PHP class to help generate a web form, based on an input of text rules separated with pipes. Based on GUMP (), by Sean Nieuwoudt ()

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
===============

[](#getting-started)

How to Use (extended):
======================

[](#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 .=
