PHP code example of rwitchell / gump-form-builder
1. Go to this page and download the library: Download rwitchell/gump-form-builder library . Choose the download type require .
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
rwitchell / gump-form-builder example snippets ``
// 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;