PHP Classes

AutoForm Generator Validator for HTML5: Generate and validate HTML5 forms

Recommend this page to a friend!
  Info   View files Example   View files View files (4)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Ratings Unique User Downloads Download Rankings
Not yet rated by the usersTotal: 265 All time: 7,752 This week: 119Up
Version License PHP version Categories
form-generator-html5 1.0GNU General Publi...5HTML, PHP 5, Validation
Description 

Author

This class can generate and validate HTML5 forms.

It can add the definition of several types of inputs to a form along with some parameters that define validation rules.

The class can also generate the HTML to display the whole form.

When the form is submitted, the class can validate the submitted values to verify if they comply with the validation rules.

Picture of Ruben Arroyo
  Performance   Level  
Name: Ruben Arroyo <contact>
Classes: 2 packages by
Country: Spain Spain
Age: 30
All time rank: 377099 in Spain Spain
Week rank: 312 Up10 in Spain Spain Up

Example

<style>
    form { display:table; }
    form > div { display:table-row; }
    form > div > div { display:table-cell; }
</style>
<?php
include 'formgenerator.php';


function
LoadData() {
   
// First mount array with parameters
   
$fr = new formGenerator();
   
$fr->logErrors = true; // It log errors when validate
   
$fr->addTextArea('Dsadas','hidden', '', 'nothing');
   
$fr->addInput('','hidden', 'UserID', 'nothing');
   
$fr->addInput('Usuario', 'text', 'username', '', true, 'Usuario', array('class' => 'prueba'));
   
$fr->addInput('Password:', 'password', 'password');
   
$fr->addInput('Email', 'email', 'email', '', false, 'Tu email');
   
$fr->addInput('Tu web', 'url', 'tu_web', 'http://', false, 'Web personal');
   
$fr->addSeparator();
   
   
$fr->addNumber('Edad', 'age', '', false, false, 2, 100, 2, false);
   
$fr->addNumber('Salario', 'salario', '', true, false, 2, 100, 2);
   
$fr->addDate('Fecha', 'fecha', '', false, false, '', '', '', false);
   
$fr->addSeparator();
   
   
$fr->addSelect('RANK', 'RANK', array('test','test2'));
   
   
   
// Some option autocreated, Is required use addRadio, NOT addINPUT
    // in this case, the value is the same that text to show, so key is optional (is incremental)
   
$fr->addRadio('Valoration', 'valoration', array(
           
0=>'0',
           
5=>'5',
           
10=>'10'
   
), null, true);
   
   
$fr->addCheck('Accept conditions', 'accept conditions', '1');
   
$fr->addSeparator();
   
   
$fr->addSubmit('send', 'Enviar');

    return
$fr;
}

// Load all form configuration
$fr = LoadData();

// Process data
if ($_POST) {
   
// Checking reply
   
if (!$fr->validate()) {
        echo
'unvalidated';
        echo
'<br /><b>ERRORS:</b><br />'.$fr->errors;
    } else {
        echo
'validated';
       
// Now you can get values and save on you like
        // or if is to manipule a database, you can use the module "FormGeneratorDB"
   
}
    echo
'<hr />';
}

// Show form everytime
$fr->showForm();
?>


Details

CURRENTLY [] IN "NAME" IS NOT SUPORTED CURRENT WORKING (fully or half) IN THIS CLASS: - INPUTS: - Text - email - website - range - number - date (mm-dd-yyyy) - Password - Checkbox - Option/radio button (with him self function to catch arrays) - select box - button - submit You can use any type of INPUT, but currently will not validated if not in the list. If you need support to any of others, tell us and will put in the next version of KernelWeb

  Files folder image Files  
File Role Description
Plain text file changelog.txt Data Changelog
Plain text file readme.txt Data Readme
Plain text file example.php Example Example
Plain text file FormGenerator.php Class Class

 Version Control Unique User Downloads Download Rankings  
 0%
Total:265
This week:0
All time:7,752
This week:119Up