PHP Classes

Complex PHP Form Design and Generator: Display and process complex HTML forms HTML forms

Recommend this page to a friend!
     
  Info   Example   View files Files   Install with Composer Install with Composer   Download Download   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not enough user ratingsTotal: 209 All time: 8,386 This week: 40Up
Version License PHP version Categories
complexformgenerator 1.0.3GNU General Publi...7HTML, PHP 5, Validation
Description 

Author

This package can display and process complex HTML forms.

It can compose HTML-based forms by adding inputs to the form definition and layout elements that define how to render the form.

The package can load the definition of the form from an XML file.

It can also load and execute a given PHP script to process the form after it is submitted.

Picture of Stefan Kientzler
  Performance   Level  
Name: Stefan Kientzler is available for providing paid consulting. Contact Stefan Kientzler .
Classes: 19 packages by
Country: Germany Germany
Age: 57
All time rank: 71446 in Germany Germany
Week rank: 27 Up1 in Germany Germany Up
Innovation award
Innovation award
Nominee: 11x

Winner: 6x

Example

<?php
declare(strict_types=1);

require_once
'../autoloader.php';

use
SKien\Config\JSONConfig;
use
SKien\Formgenerator\ArrayFormData;
use
SKien\Formgenerator\FormGenerator;
use
SKien\Formgenerator\FormInput;
use
SKien\Formgenerator\FormFlags;
use
SKien\Formgenerator\FormSelect;
use
SKien\Formgenerator\FormStatic;
use
SKien\Formgenerator\FormDate;
use
SKien\Formgenerator\FormTime;
use
SKien\Formgenerator\FormButtonBox;
use
SKien\Formgenerator\FormCur;
use
SKien\Formgenerator\FormColor;
use
SKien\Formgenerator\FormHeader;
use
SKien\Formgenerator\FormFloat;
use
SKien\Formgenerator\FormRange;

// $strTheme = './MSO-Theme/';
$strTheme = './';

$oConfig = new JSONConfig($strTheme . 'FormGenerator.json');

$dtTo = new DateTime();
$dtTo->setTimestamp(time() + 3600);
$aData = [
   
'username' => 'Stefanius',
   
'strLastname' => 'Mustermann',
   
'strFirstname' => 'Max',
   
'strStreet' => 'Hammerstraße',
   
'strPostcode' => '12345',
   
'strCity' => 'Musterstadt',
   
'strGender' => 'm',
   
'dateDoB' => '1974-07-23',
   
'timeAvailableFrom' => time(),
   
'timeAvailableTo' => $dtTo,
   
'fltDue' => 1904,
   
'strCatColor' => '#B0BED0',
   
'fltWeight' => 71.3,
   
'iPriority' => 3,
];

$aGenderSelect = ['' => '', 'männlich' => 'm', 'weiblich' => 'f', 'divers' => 'd'];
$aCitySelect = ['München', 'Berlin', 'Köln', 'Hamburg'];

$oData = new ArrayFormData($aData, ['strGender' => $aGenderSelect, 'strCity' => $aCitySelect]);

$oFG = new FormGenerator($oData);
$oFG->setConfig($oConfig);
$oFG->setAction('formaction.php');
$oFG->setTarget('_blank');
// $oFG->setReadOnly(true);
// $oFG->setDebugMode(true);

$oFG->setColWidth([20, 80], '%');

$oFG->add(new FormHeader('Personnel data sheet', 1));

$oFS = $oFG->addFieldSet('Name');
$oFL = $oFS->addLine('Lastname:');
$oInput = new FormInput('strLastname', '100%', FormFlags::MANDATORY);
$oInput->setMaxLength(50);
$oFL->add($oInput);
$oFL = $oFS->addLine('Firstname:');
$oFL->add(new FormInput('strFirstname', '100%', 0, 50));
$oFS = $oFG->addFieldSet('Address');
$oFL = $oFS->addLine('Region:');
$oEdit = new FormInput('strRegion', '100%');
$oFL->add($oEdit);
$oEdit->setPlaceholder('enter Region');
$oFL = $oFS->addLine('Street:');
$oFL->add(new FormInput('strStreet', '100%'));
$oFL = $oFS->addLine('Postcode, City:');
$oFL->setColWidth([20, 20, 60], '%');
$oFL->add(new FormInput('strPostcode', '90%'));
$oFL->add(new FormInput('strCity', '100%'));
$oFS = $oFG->addFieldSet('some personal Data');
$oFS->setColWidth([20, 30, 20, 30], '%');
$oFL = $oFS->addLine();
$oFL->setColWidth([0, 100], '%');
$oFL->add(new FormStatic('And here are some informations...', FormFlags::INFO | FormFlags::BOLD));
$oFL = $oFS->addLine('Gender:');
$oFL->add(new FormSelect('strGender', 1, FormFlags::MANDATORY));
$oFL->add(new FormStatic('Date of Birth:'));
$oFL->add(new FormDate('dateDoB', FormFlags::NO_ZERO | FormFlags::ADD_DATE_PICKER));
$oFL = $oFS->addLine('Available from:');
$oFL->add(new FormTime('timeAvailableFrom', FormFlags::ADD_TIME_PICKER));
$oFL->add(new FormStatic('to:'));
$oFL->add(new FormTime('timeAvailableTo', FormFlags::ADD_TIME_PICKER));
$oFL = $oFS->addLine('Member due:');
$oFL->add(new FormCur('fltDue', 10, FormFlags::ADD_CUR));
$oFL->add(new FormStatic('extra fee:'));
$oFL->add(new FormCur('fltExtra', 10, FormFlags::ADD_CUR | FormFlags::NO_ZERO));
$oFL = $oFS->addLine('Weight:');
$oFloat = new FormFloat('fltWeight', 10, 1);
$oFL->add($oFloat);
$oFloat->setSuffix('kg');
$oFL = $oFS->addLine('Priority:');
// $oFL->add(new FormInt('iPriority', 8));
$oFL->add(new FormRange('iPriority', '70%', 1, 10, FormFlags::SHOW_VALUE));
$oFL->add(new FormStatic('category:'));
$oFL->add(new FormColor('strCatColor'));
$oFL = $oFS->addLine('Resumé:');
$oFL->setColWidth([20, 80], '%');
$oEdit = new FormInput('strResumeFile', 'calc(100% - 45px)', FormFlags::BROWSE_SERVER | FormFlags::READ_ONLY);
$oEdit->setExpandFolder('files/');
$oFL->add($oEdit);
$oFS = $oFG->addFieldSet('internal processing');
$oFL = $oFS->addLine('Validated:');
$oFL->add(new FormInput('strValidated', 30, FormFlags::ADD_DTU | FormFlags::READ_ONLY));

$oFG->add(new FormButtonBox(FormButtonBox::SAVE | FormButtonBox::DISCARD, FormFlags::ALIGN_RIGHT));

// generate HTML-markup and JS configuration data
$strFormHTML = $oFG->getForm();
$strStyleFromPHP = $oFG->getStyle();
$strConfigFromPHP = $oFG->getScript();
?>
<html>
<head>
<link type="text/css" rel="stylesheet" href="<?= $strTheme; ?>FormGenerator.css">
<style>
body
{
    background-color: #777;
    width: 100%;
    padding-top: 20px;
}

<?php echo $strStyleFromPHP; ?>
</style>
<script type="text/javascript" src="../script/FormGenerator.js"></script>
<script>
<?php echo $strConfigFromPHP; ?>
</script>
</head>
<body>
<div style="width:600px; margin: 0px auto; background-color: transparent;">
<?php echo $strFormHTML; ?>
</div>
</body>
</html>


Details

Create complex HTML forms

State License Donate Minimum PHP Version Scrutinizer Code Quality

Overview

This package can be used to create complex input forms. Multiple input fields can be arranged in rows or in several columns.

In addition to the 'usual' form elements, the package contains an element for entering color values and a range element to which a label can be assigned, in which the current selection of the slider is automatically displayed.

Additionaly the package contains JavaScript-based pickers for - date fields - time fields - color fields

and integrated JS validation of - date values - time values - numerical values (integer, floating point and currency fields).

The input formats can be configured to meet country-specific requirements. The design can be completely adapted to your own needs using an individual stylesheet.

The form definition can be made directly in the PHP code or within a XML file (for this purposes a XSD schema is provided with the package to make it easy to check the validation of the XML definition).

The package also contains an element that can be used to integrate the WYSIWYG editor 'CKEditor 4' into a form. The complete configuration is done from the PHP side. A connector to the open source file manager 'RichFilemanager' is included for selecting graphics or to create links to other files on the server.

Documentation

As this package supplies a wide range of functionality that can be configured individual, the documentation is splitted into multiple parts:

  1. The configuration of the package
  2. Quickstart with a simple example form
  3. ... to be continued

In the example directory you will find sample forms that show the use of all supported elements and currently provides two different themes.


  Files folder image Files (142)  
File Role Description
Files folder imagedoc (9 files)
Files folder imageexamples (11 files, 4 directories)
Files folder imagescript (9 files)
Files folder imageSKien (3 directories)
Accessible without login Plain text file autoloader.php Aux. Auxiliary script
Accessible without login Plain text file LICENSE Lic. License text
Accessible without login Plain text file phpstan.neon Data Auxiliary data
Accessible without login Plain text file phpunit.xml Data Auxiliary data
Accessible without login Plain text file readme.md Doc. Documentation

  Files folder image Files (142)  /  doc  
File Role Description
  Accessible without login Plain text file BasicFormstructure.svg Data Auxiliary data
  Accessible without login Plain text file FG-config.md Data Auxiliary data
  Accessible without login Plain text file FG-quickstart.md Data Auxiliary data
  Accessible without login Plain text file Formgenerator.svg Data Auxiliary data
  Accessible without login Plain text file FormgeneratorClassdiagram.pdf Data Auxiliary data
  Accessible without login Image file FormgeneratorClassdiagram.png Data Auxiliary data
  Accessible without login Image file QuickStartMSO.png Icon Icon image
  Accessible without login Image file QuickStartSKien.png Icon Icon image
  Accessible without login Image file QuickStartStructure.png Icon Icon image

  Files folder image Files (142)  /  examples  
File Role Description
Files folder imageimages (2 files)
Files folder imageMSO-Theme (10 files)
Files folder imagepublic (1 directory)
Files folder imagexml (4 files)
  Accessible without login Plain text file CKEditorForm.php Example Example script
  Accessible without login Plain text file ColumnForm.php Example Example script
  Accessible without login Plain text file ColumnFormXML.php Example Example script
  Accessible without login Plain text file formaction.php Aux. Auxiliary script
  Accessible without login Plain text file FormGenerator.css Data Auxiliary data
  Accessible without login Plain text file FormGenerator.json Data Auxiliary data
  Accessible without login Plain text file QuickStart.php Example Example script
  Accessible without login Plain text file QuickStartXML.php Example Example script
  Accessible without login Plain text file SimpleForm.php Example Example script
  Accessible without login Plain text file SimpleFormXML.php Example Example script
  Accessible without login Plain text file TextAreaForm.php Example Example script

  Files folder image Files (142)  /  examples  /  images  
File Role Description
  Accessible without login Image file info.png Icon Icon image
  Accessible without login Image file window_close.png Icon Icon image

  Files folder image Files (142)  /  examples  /  MSO-Theme  
File Role Description
  Accessible without login Image file browse.png Icon Icon image
  Accessible without login Image file datepicker.png Icon Icon image
  Accessible without login Image file delete.png Icon Icon image
  Accessible without login Plain text file FormGenerator.css Data Auxiliary data
  Accessible without login Plain text file FormGenerator.json Data Auxiliary data
  Accessible without login Image file info.png Icon Icon image
  Accessible without login Image file insert_dtu.png Icon Icon image
  Accessible without login Image file search.png Icon Icon image
  Accessible without login Image file timepicker.png Icon Icon image
  Accessible without login Image file window_close.png Icon Icon image

  Files folder image Files (142)  /  examples  /  public  
File Role Description
Files folder imageimages (3 files)

  Files folder image Files (142)  /  examples  /  public  /  images  
File Role Description
  Accessible without login Image file contact_empty.png Icon Icon image
  Accessible without login Image file sample1.jpg Icon Icon image
  Accessible without login Image file sample2.png Icon Icon image

  Files folder image Files (142)  /  examples  /  xml  
File Role Description
  Accessible without login Plain text file ColumnForm.xml Data Auxiliary data
  Accessible without login Plain text file FormGenerator.xsd Data Auxiliary data
  Accessible without login Plain text file QuickStart.xml Data Auxiliary data
  Accessible without login Plain text file SimpleForm.xml Data Auxiliary data

  Files folder image Files (142)  /  script  
File Role Description
  Accessible without login Plain text file dtsel-LICENSE Lic. License text
  Accessible without login Plain text file dtsel.js Data Auxiliary data
  Accessible without login Plain text file FormCKEdit.js Data Auxiliary data
  Accessible without login Plain text file FormDataValidator.js Data Auxiliary data
  Accessible without login Plain text file FormGenerator.js Data Auxiliary data
  Accessible without login Plain text file FormPicker.js Data Auxiliary data
  Accessible without login Plain text file jscolor.js Data Auxiliary data
  Accessible without login Plain text file jscolor.min.js Data Auxiliary data
  Accessible without login Plain text file RichFmConnector.js Data Auxiliary data

  Files folder image Files (142)  /  SKien  
File Role Description
Files folder imageConfig (4 files)
Files folder imageFormgenerator (34 files, 1 directory)
Files folder imageTest (1 directory)

  Files folder image Files (142)  /  SKien  /  Config  
File Role Description
  Plain text file AbstractConfig.php Class Class source
  Plain text file ConfigInterface.php Class Class source
  Plain text file JSONConfig.php Class Class source
  Plain text file NullConfig.php Class Class source

  Files folder image Files (142)  /  SKien  /  Formgenerator  
File Role Description
Files folder imageStdImages (6 files)
  Plain text file AbstractFormData.php Class Class source
  Plain text file ArrayFormData.php Class Class source
  Plain text file FormButton.php Class Class source
  Plain text file FormButtonBox.php Class Class source
  Plain text file FormCanvas.php Class Class source
  Plain text file FormCheck.php Class Class source
  Plain text file FormCKEdit.php Class Class source
  Plain text file FormCollection.php Class Class source
  Plain text file FormColor.php Class Class source
  Plain text file FormCur.php Class Class source
  Plain text file FormDataInterface.php Class Class source
  Plain text file FormDate.php Class Class source
  Plain text file FormDiv.php Class Class source
  Plain text file FormElement.php Class Class source
  Plain text file FormElementInterface.php Class Class source
  Plain text file FormFieldSet.php Class Class source
  Plain text file FormFlags.php Class Class source
  Plain text file FormFloat.php Class Class source
  Plain text file FormGenerator.php Class Class source
  Plain text file FormHeader.php Class Class source
  Plain text file FormImage.php Class Class source
  Plain text file FormInput.php Class Class source
  Plain text file FormInt.php Class Class source
  Plain text file FormLine.php Class Class source
  Plain text file FormRadioGroup.php Class Class source
  Plain text file FormRange.php Class Class source
  Plain text file FormScript.php Class Class source
  Plain text file FormSelect.php Class Class source
  Plain text file FormStatic.php Class Class source
  Plain text file FormTextArea.php Class Class source
  Plain text file FormTime.php Class Class source
  Plain text file NullFormData.php Class Class source
  Plain text file XMLForm.php Class Class source
  Plain text file XMLHelper.php Class Class source

  Files folder image Files (142)  /  SKien  /  Formgenerator  /  StdImages  
File Role Description
  Accessible without login Image file browse.png Icon Icon image
  Accessible without login Image file datepicker.png Icon Icon image
  Accessible without login Image file delete.png Icon Icon image
  Accessible without login Image file insert_dtu.png Icon Icon image
  Accessible without login Image file search.png Icon Icon image
  Accessible without login Image file timepicker.png Icon Icon image

  Files folder image Files (142)  /  SKien  /  Test  
File Role Description
Files folder imageFormgenerator (28 files, 1 directory)

  Files folder image Files (142)  /  SKien  /  Test  /  Formgenerator  
File Role Description
Files folder imagetestdata (17 files)
  Plain text file ArrayFormDataTest.php Class Class source
  Plain text file FormBaseTestCase.php Class Class source
  Plain text file FormButtonBoxTest.php Class Class source
  Plain text file FormButtonTest.php Class Class source
  Plain text file FormCanvasTest.php Class Class source
  Plain text file FormCheckTest.php Class Class source
  Plain text file FormCKEditTest.php Class Class source
  Plain text file FormColorTest.php Class Class source
  Plain text file FormCurTest.php Class Class source
  Plain text file FormDateTest.php Class Class source
  Plain text file FormDivTest.php Class Class source
  Plain text file FormFieldSetTest.php Class Class source
  Plain text file FormFloatTest.php Class Class source
  Plain text file FormgeneratorHelper.php Class Class source
  Plain text file FormgeneratorTest.php Class Class source
  Plain text file FormHeaderTest.php Class Class source
  Plain text file FormImageTest.php Class Class source
  Plain text file FormInputTest.php Class Class source
  Plain text file FormIntTest.php Class Class source
  Plain text file FormLineTest.php Class Class source
  Plain text file FormRadioGroupTest.php Class Class source
  Plain text file FormRangeTest.php Class Class source
  Plain text file FormScriptTest.php Class Class source
  Plain text file FormSelectTest.php Class Class source
  Plain text file FormStaticTest.php Class Class source
  Plain text file FormTextAreaTest.php Class Class source
  Plain text file FormTimeTest.php Class Class source
  Plain text file XMLFormTest.php Class Class source

  Files folder image Files (142)  /  SKien  /  Test  /  Formgenerator  /  testdata  
File Role Description
  Accessible without login Plain text file AllElements.xml Data Auxiliary data
  Accessible without login Plain text file FormErrorFormGenerator.xml Data Auxiliary data
  Accessible without login Plain text file FormErrorUnknownButton.xml Data Auxiliary data
  Accessible without login Plain text file FormErrorUnknownDivAlign.xml Data Auxiliary data
  Accessible without login Plain text file FormErrorUnknownElement.xml Data Auxiliary data
  Accessible without login Plain text file FormErrorUnknownFieldSetType.xml Data Auxiliary data
  Accessible without login Plain text file FormErrorUnknownFlag.xml Data Auxiliary data
  Accessible without login Plain text file FormErrorWithSchema.xml Data Auxiliary data
  Accessible without login Plain text file FormErrorXML.xml Data Auxiliary data
  Accessible without login Plain text file FormGenerator.xsd Data Auxiliary data
  Accessible without login Plain text file FormGeneratorDE.json Data Auxiliary data
  Accessible without login Plain text file FormGeneratorSpecial.json Data Auxiliary data
  Accessible without login Plain text file FormInput.xml Data Auxiliary data
  Accessible without login Plain text file FormLine.xml Data Auxiliary data
  Accessible without login Plain text file FormMissing.xml Data Auxiliary data
  Accessible without login Plain text file FormRootMissing.xml Data Auxiliary data
  Accessible without login Plain text file FormWithSchema.xml Data Auxiliary data

The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page.
Install with Composer Install with Composer
 Version Control Unique User Downloads Download Rankings  
 100%
Total:209
This week:0
All time:8,386
This week:40Up
User Comments (1)
Works as documented.
3 years ago (Rick Ruggiero)
72%StarStarStarStar