-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathform.php
More file actions
46 lines (38 loc) · 1.36 KB
/
form.php
File metadata and controls
46 lines (38 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
require_once('element.php');
if (!class_exists('Form')) {
class Form {
private static $formDefaults;
public $form;
public function init () {
$formDefaults = array();
}
public function __construct (array $attributes) {
$form = new Element('form');
//Add default attributes for unset attributes
foreach (self::$formDefaults as $attribute => $value) {
if (!isset($attributes[$attribute])) {
$attributes[$attribute] = $value;
}
}
//Apply attributes to form
foreach ($attributes as $attribute => $value) {
$form->$attribute = $value;
}
}
public static function setDefault($attribute, $value) {
if ($value == null) {
unset(self::$formDefaults[$attribute]);
} else {
self::$formDefaults[$attribute] = $value;
}
}
public static function setDefaults(array $attributes) {
foreach ($attributes as $attribute => $value) {
self::setDefault($attribute, $value);
}
}
}
Form::init();
}
?>