-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathform.php
More file actions
107 lines (93 loc) · 1.86 KB
/
form.php
File metadata and controls
107 lines (93 loc) · 1.86 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
<?php
/**
* Form.
*
*
*
*/
class Form extends HTML5
{
/**
* Additional field attributes stored in key/value pairs
* @var array $_attributes
*/
protected $_action;
/**
* Fields array
* @var array $_fields
*/
protected $_fields;
/**
* Fields array
* @var array $_options
*/
protected $_options;
/**
* Class Constructor
*
* This class constructor instantiates the creation of a new form field
* element contained in the HTML5 Helper.
*
* @param string $name (required)
* @param string $action (required)
* @param array $options (optional)
*/
function __construct( $action, $options = array() )
{
$this->_action = $action;
$this->_fields = array();
$this->_options = $options;
}
/**
* Text Field.
*
* Creates an <input type="text"> field.
*
* @param string $name
* @param array $options
*/
function text_field( $name, $value = null, $options = array() )
{
$field = new Form_Field( 'text', $name, $value, $options );
$field = $field->render();
return $field;
}
/**
* Text Box.
*
* Creates a <textarea> field.
*
* @param string $name
* @param array $options
*/
function text_box( $name, $value = null, $options = array() )
{
$field = new Form_Field( 'textarea', $name, $value, $options );
$field = $field->render();
return $field;
}
/**
* Select.
*
* Creates a <select> field with options.
*
* @param string $name
* @param array $options
*/
function select_box( $name, $value = null, $collection = array(), $options = array() )
{
$options['collection'] = $collection;
$field = new Form_Field( 'select', $name, $value, $options );
$field = $field->render();
return $field;
}
function add( $field )
{
$this->_fields[] = $field;
}
function render()
{
return $this->form( $this->_action, join( "", $this->_fields ), $this->_options );
}
}
?>