-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtabularform.class
More file actions
108 lines (88 loc) · 3.13 KB
/
Copy pathtabularform.class
File metadata and controls
108 lines (88 loc) · 3.13 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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
<?php
class TabularForm extends Table {
private $Form = NULL;
private $RowType = false;
protected $Select = NULL;
private $SelectedValue = NULL;
public function __construct($caption, $css_class) {
parent::__construct($caption, NULL, $css_class);
$this->AddElement('id', $css_class);
}
public function AddForm($form) {
$this->Form = $form;
if ($this->Row === NULL) {
$body = $this->Body;
$this->Body = $form;
$this->Body->AddChild($body);
} else {
$this->RowType = true;
}
}
public function NewRow($css_class=NULL) {
if ($this->RowType === true) {
$this->Form->AddChild($this->Row);
$this->Row = $this->Form;
$this->RowType = false;
}
parent::NewRow($css_class);
}
public function AddText($name, $value=NULL, $maxlength=255) {
$this->AddSelectChild();
$css_class = ereg_replace("\[.*\]", "", $name);
$element = new FormElement();
$input = new FormInput('text', $name, $value, $maxlength);
$element->AddChild($input->Build());
$element->AddElement('class', $css_class);
$this->AddCell($element, $css_class);
}
public function AddCheckbox($name, $value=NULL) {
$this->AddSelectChild();
$css_class = ereg_replace("\[.*\]", "", $name);
$element = new FormElement();
$input = new FormInput('checkbox', $name, $value);
$element->AddChild($input->Build());
$this->AddCell($element, $css_class);
}
public function AddHidden($name, $value=NULL) {
$this->AddSelectChild();
$element = new FormElement();
$input = new FormInput('hidden', $name, $value);
$element->AddChild($input->Build());
$this->AddCell($element);
}
public function NewSelect($name, $value=NULL) {
$this->AddSelectChild();
$css_class = ereg_replace("\[.*\]", "", $name);
$this->Select = new FormSelect($name);
$this->SelectedValue = $value;
$this->Select->SetAttribute('class', $css_class);
}
public function AddSelectOption($name, $value=NULL) {
if ($this->SelectedValue != NULL && $value == $this->SelectedValue)
$this->Select->AddOption($name, $value, true);
elseif ($this->SelectedValue != NULL && $name == $this->SelectedValue)
$this->Select->AddOption($name, $value, true);
else
$this->Select->AddOption($name, $value);
}
public function AddSubmit($value='Submit', $name='submit') {
$this->AddSelectChild();
$element = new FormElement();
$input = new FormInput('submit', $name, $value);
$element->AddChild($input->Build());
$this->AddCell($element);
}
public function AddSelectChild() {
if ($this->Select != NULL) {
$element = new FormElement();
$element->AddChild($this->Select);
$this->AddCell($element);
$this->Select = NULL;
}
}
public function Build() {
$this->Form->Validate();
parent::Build();
}
}
?>