blob: ffee3d7823506a16b9689cced9d602b67888cfb5 (
plain) (
tree)
|
|
<?php
/*
* Model web-forms and simplify the process of accepting, validating, and sanitizing input
*/
class Form
{
/*
* Constructor
*/
function __construct()
{
$this->textFields = array();
$this->numbFields = array();
$this->enumFields = array();
$this->errorlist = array();
$this->warninglist = array();
$this->noticelist = array();
}
/*
* Add new text field to the form
*/
function field_text($name, $req = true)
{
if ($req !== true)
$req = false;
$this->textFields[] = array(
'name' => $name,
'req' => $req
);
}
/*
* Add new numeric field to the form
*/
function field_numeric($name, $req = true, $integer = true, $min = null, $max = null)
{
if ($req !== true)
$req = false;
if ($integer !== true)
$integer = false;
$this->numbFields[] = array(
'name' => $name,
'req' => $req,
'int' => $integer,
'min' => $min,
'max' => $max
);
}
/*
* Add new enumeration field to the form
*/
function field_enum($name, $req = true, $values)
{
if ($req !== true)
$req = false;
$this->enumFields[] = array(
'name' => $name,
'req' => $req,
'vals' => $values
);
}
}
?>
|