1 |
<?php |
2 |
|
3 |
/** |
4 |
* A simple Page Layout object child. |
5 |
* this came from Example 3. |
6 |
* |
7 |
* @author Walter A. Boring IV <waboring@buildabetterweb.com> |
8 |
* @package phpHtmlLib |
9 |
* @subpackage form-examples |
10 |
*/ |
11 |
class Step1 extends StandardFormContent { |
12 |
|
13 |
/** |
14 |
* This method gets called EVERY time the object is |
15 |
* created |
16 |
*/ |
17 |
function form_init_elements() { |
18 |
$this->add_element( new FEText("First Name", TRUE, 20) ); |
19 |
|
20 |
$password = new FEPassword("Password", TRUE); |
21 |
$this->add_element( $password ); |
22 |
|
23 |
$confirm = new FEConfirmPassword("Confirm Password", TRUE); |
24 |
$confirm->password( $password ); |
25 |
$this->add_element( $confirm ); |
26 |
|
27 |
$this->add_element( new FEEmail("Email Address", TRUE, "200px") ); |
28 |
} |
29 |
|
30 |
/** |
31 |
* This method is called only the first time the form |
32 |
* page is hit. |
33 |
*/ |
34 |
function form_init_data() { |
35 |
//Pull some valies from the DB |
36 |
//and set the initial values of some of the |
37 |
//form fields. |
38 |
// |
39 |
//In this example we just hard code some |
40 |
//initial values |
41 |
$this->set_element_value("First Name", "testing"); |
42 |
} |
43 |
|
44 |
/** |
45 |
* This method is called by the StandardFormContent object |
46 |
* to allow you to build the 'blocks' of fields you want to |
47 |
* display. Each form block will live inside a fieldset tag |
48 |
* with the a title. |
49 |
* |
50 |
* In this example we have 2 form 'blocks'. |
51 |
*/ |
52 |
function form_content() { |
53 |
$this->add_form_block("User Info", $this->_user_info() ); |
54 |
} |
55 |
|
56 |
/** |
57 |
* This private method builds the table that holds |
58 |
* the 'user' form fields' |
59 |
* |
60 |
*/ |
61 |
function &_user_info() { |
62 |
$table = &html_table($this->_width,0,2); |
63 |
$table->add_row($this->element_label("First Name"), |
64 |
$this->element_form("First Name")); |
65 |
|
66 |
$table->add_row($this->element_label("Email Address"), |
67 |
$this->element_form("Email Address")); |
68 |
|
69 |
$table->add_row($this->element_label("Password"), |
70 |
$this->element_form("Password")); |
71 |
|
72 |
$table->add_row($this->element_label("Confirm Password"), |
73 |
$this->element_form("Confirm Password")); |
74 |
|
75 |
return $table; |
76 |
} |
77 |
|
78 |
/** |
79 |
* This method gets called after the FormElement data has |
80 |
* passed the validation, and has been confirmed. This |
81 |
* enables you to validate the data against some backend |
82 |
* mechanism, say a DB. |
83 |
* |
84 |
*/ |
85 |
function form_backend_validation() { |
86 |
//HARD CODE an error here to show how to show an error |
87 |
//and that it will prevent the confirm_action() method |
88 |
//from being called |
89 |
//$this->add_error("First Name", "Duplicate!! You suck!"); |
90 |
return TRUE; |
91 |
} |
92 |
|
93 |
/** |
94 |
* This method will get called after all validation has |
95 |
* passed, and the confirmation has been accepted. |
96 |
* |
97 |
* This is where u save the info to the DB. |
98 |
*/ |
99 |
function confirm_action() { |
100 |
//$this->set_action_message("WOO!"); |
101 |
return TRUE; |
102 |
} |
103 |
} |
104 |
|
105 |
|
106 |
class Step2 extends StandardFormContent { |
107 |
|
108 |
/** |
109 |
* This method gets called EVERY time the object is |
110 |
* created |
111 |
*/ |
112 |
function form_init_elements() { |
113 |
|
114 |
//This will build a scrollable list of checkboxes. |
115 |
$this->add_element( new FECheckBoxList("List", FALSE, |
116 |
"200px", "80px", |
117 |
array("Testing 123" => "foo", |
118 |
"What is this?" => "bar", |
119 |
"Somone's test" => "blah", |
120 |
"Slerm" => "slerm", |
121 |
"Flem" => "flom", |
122 |
"One" => 1))); |
123 |
|
124 |
$this->add_element( new FEListBox("Anrede", FALSE, "100px", NULL,array("Frau"=>0,"Herr"=>1)) ); |
125 |
|
126 |
//build a large textarea |
127 |
$this->add_element( new FETextArea("Comment", TRUE, 20,10,"400px", "100px" ) ); |
128 |
|
129 |
$this->add_hidden_element( "foo" ); |
130 |
|
131 |
$this->add_element( new FECheckBox ("Patient Contact1", "Daytime Phone") ); |
132 |
$this->add_element( new FECheckBox ("Patient Contact2", "Evening Phone") ); |
133 |
$this->add_element( new FECheckBox ("Patient Contact3", "Email") ); |
134 |
|
135 |
} |
136 |
|
137 |
/** |
138 |
* This method is called only the first time the form |
139 |
* page is hit. |
140 |
*/ |
141 |
function form_init_data() { |
142 |
//Pull some valies from the DB |
143 |
//and set the initial values of some of the |
144 |
//form fields. |
145 |
// |
146 |
//set a few of the checkboxlist items as checked. |
147 |
$this->set_element_value("List", array("bar","slerm",1)); |
148 |
|
149 |
//change the value of the hidden form field |
150 |
$this->set_hidden_element_value("foo", "hemna"); |
151 |
} |
152 |
|
153 |
/** |
154 |
* This method is called by the StandardFormContent object |
155 |
* to allow you to build the 'blocks' of fields you want to |
156 |
* display. Each form block will live inside a fieldset tag |
157 |
* with the a title. |
158 |
* |
159 |
* In this example we have 2 form 'blocks'. |
160 |
*/ |
161 |
function form_content() { |
162 |
$this->add_form_block("Optional", $this->_optional_info() ); |
163 |
} |
164 |
|
165 |
|
166 |
/** |
167 |
* This private method builds the table that holds |
168 |
* the 'optional' form fields' |
169 |
* |
170 |
*/ |
171 |
function &_optional_info() { |
172 |
$table = &html_table($this->_width,0,2); |
173 |
|
174 |
$table->add_row($this->element_label("Anrede"), |
175 |
$this->element_form("Anrede")); |
176 |
|
177 |
$table->add_row($this->element_label("List"), |
178 |
$this->element_form("List")); |
179 |
|
180 |
$table->add_row($this->element_label("Comment"), |
181 |
$this->element_form("Comment")); |
182 |
|
183 |
$td = new TDtag( array("colspan" => 2), |
184 |
$this->element_form("Patient Contact1"), |
185 |
$this->element_form("Patient Contact2"), |
186 |
$this->element_form("Patient Contact3") ); |
187 |
|
188 |
$table->add_row( $td ); |
189 |
|
190 |
return $table; |
191 |
} |
192 |
|
193 |
/** |
194 |
* This method will get called after all validation has |
195 |
* passed, and the confirmation has been accepted. |
196 |
* |
197 |
* This is where u save the info to the DB. |
198 |
*/ |
199 |
function confirm_action() { |
200 |
//$this->set_action_message("WOO!"); |
201 |
return TRUE; |
202 |
} |
203 |
} |
204 |
|
205 |
|
206 |
class Step3 extends StandardFormContent { |
207 |
|
208 |
/** |
209 |
* This method gets called EVERY time the object is |
210 |
* created |
211 |
*/ |
212 |
function form_init_elements() { |
213 |
|
214 |
$this->add_element( new FEIPAddress ("My IP", TRUE) ); |
215 |
$this->add_element( new FEUrl("Home Page") ); |
216 |
$this->add_element( new FENumberPrice("Dollar Amount") ); |
217 |
|
218 |
} |
219 |
|
220 |
/** |
221 |
* This method is called only the first time the form |
222 |
* page is hit. |
223 |
*/ |
224 |
function form_init_data() { |
225 |
//Pull some valies from the DB |
226 |
//and set the initial values of some of the |
227 |
//form fields. |
228 |
// |
229 |
//set a few of the checkboxlist items as checked. |
230 |
$this->set_element_value("Home Page", "http://www.cnn.com"); |
231 |
} |
232 |
|
233 |
/** |
234 |
* This method is called by the StandardFormContent object |
235 |
* to allow you to build the 'blocks' of fields you want to |
236 |
* display. Each form block will live inside a fieldset tag |
237 |
* with the a title. |
238 |
* |
239 |
* In this example we have 2 form 'blocks'. |
240 |
*/ |
241 |
function form_content() { |
242 |
$this->add_form_block("Settings", $this->_optional_info() ); |
243 |
} |
244 |
|
245 |
|
246 |
/** |
247 |
* This private method builds the table that holds |
248 |
* the 'optional' form fields' |
249 |
* |
250 |
*/ |
251 |
function &_optional_info() { |
252 |
$table = &html_table($this->_width,0,2); |
253 |
|
254 |
$table->add_row($this->element_label("My IP"), |
255 |
$this->element_form("My IP")); |
256 |
|
257 |
$table->add_row($this->element_label("Home Page"), |
258 |
$this->element_form("Home Page")); |
259 |
|
260 |
$table->add_row($this->element_label("Dollar Amount"), |
261 |
$this->element_form("Dollar Amount")); |
262 |
|
263 |
return $table; |
264 |
} |
265 |
|
266 |
/** |
267 |
* This method will get called after all validation has |
268 |
* passed, and the confirmation has been accepted. |
269 |
* |
270 |
* This is where u save the info to the DB. |
271 |
*/ |
272 |
function confirm_action() { |
273 |
//$this->set_action_message("WOO!"); |
274 |
return TRUE; |
275 |
} |
276 |
} |
277 |
|
278 |
?> |