-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathlib_form_helper.php
46 lines (37 loc) · 1.32 KB
/
lib_form_helper.php
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
<?php
require_once 'lib.php';
function print_text_input($label, $name, $value = "") {
echo "<tr><th>{$label}</th><td><input type=\"text\" name=\"{$name}\" value=\"{$value}\" /> </td></tr>";
}
function print_password_input($label, $name, $value = "") {
echo "<tr><th>{$label}</th><td><input type=\"password\" name=\"{$name}\" value=\"{$value}\" /> </td></tr>";
}
function print_file_input($label, $name) {
echo "<tr><th>{$label}</th><td>";
echo "<input type=\"file\" name=\"{$name}\" /></td></tr>";
}
function print_submit($label, $name = "action") {
echo "<tr><td colspan=\"2\" class=\"buttons\"><input type=\"submit\" name=\"{$name}\" value=\"{$label}\" /></td></tr>";
}
function print_select($name, $options = array(), $selected = NULL) {
echo "<select name=\"{$name}\">";
if (!is_assoc($options)) {
$new_options = array();
foreach ($options as $option) {
$new_options[$option] = $option;
}
}
foreach ($options as $option => $text) {
$setxt = "";
if (!is_null($selected) && $selected == $option) {
$setxt = " selected";
}
echo "<option value=\"{$option}\"{$setxt}>{$text}</option>";
}
echo "</select>";
}
function print_select_input($label, $name, $options, $selected = NULL) {
echo "<tr><th>{$label}</th><td>";
print_select($name, $options, $selected);
echo "</td></tr>";
}