summaryrefslogtreecommitdiffstats
path: root/app/class/form.class.php
diff options
context:
space:
mode:
Diffstat (limited to 'app/class/form.class.php')
-rw-r--r--app/class/form.class.php38
1 files changed, 25 insertions, 13 deletions
diff --git a/app/class/form.class.php b/app/class/form.class.php
index 502e348..e50876d 100644
--- a/app/class/form.class.php
+++ b/app/class/form.class.php
@@ -28,21 +28,22 @@ class Form
/*
* Add new text field to the form
*/
- function field_text($name, $req = true)
+ function field_text($name, $deflt = null, $req = true)
{
if ($req !== true)
$req = false;
$this->textFields[] = array(
- 'name' => $name,
- 'req' => $req
+ 'name' => $name,
+ 'deflt' => $deflt,
+ 'req' => $req
);
}
/*
* Add new numeric field to the form
*/
- function field_numeric($name, $req = true, $integer = true, $min = null, $max = null)
+ function field_numeric($name, $min = null, $max = null, $deflt = null, $integer = true, $req = true)
{
if ($req !== true)
$req = false;
@@ -51,26 +52,28 @@ class Form
$integer = false;
$this->numbFields[] = array(
- 'name' => $name,
- 'req' => $req,
- 'int' => $integer,
- 'min' => $min,
- 'max' => $max
+ 'name' => $name,
+ 'min' => $min,
+ 'max' => $max,
+ 'deflt' => $deflt,
+ 'int' => $integer,
+ 'req' => $req
);
}
/*
* Add new enumeration field to the form
*/
- function field_enum($name, $req = true, $values)
+ function field_enum($name, $values, $deflt = null, $req = true)
{
if ($req !== true)
$req = false;
$this->enumFields[] = array(
- 'name' => $name,
- 'req' => $req,
- 'vals' => $values
+ 'name' => $name,
+ 'vals' => $values,
+ 'deflt' => $deflt,
+ 'req' => $req
);
}
@@ -100,6 +103,9 @@ class Form
if (isset($input[$fld['name']]))
$this->$fld['name'] = htmlEntities($input[$fld['name']], ENT_QUOTES);
+ else if (!is_null($fld['deflt']))
+ $this->$fld['name'] = $fld['deflt'];
+
else if ($fld['req'])
$this->logError($fld['name'] . " is required");
}
@@ -136,6 +142,9 @@ class Form
$this->$fld['name'] = $input[$fld['name']];
}
+ else if (!is_null($fld['deflt']))
+ $this->$fld['name'] = $fld['deflt'];
+
else if ($fld['req'])
$this->logError($fld['name'] . " is required");
}
@@ -154,6 +163,9 @@ class Form
$this->$fld['name'] = $input[$fld['name']];
}
+ else if (!is_null($fld['deflt']))
+ $this->$fld['name'] = $fld['deflt'];
+
else if ($fld['req'])
$this->logError($fld['name'] . " is required");
}