1 | <?php |
||
9 | class Formaggio |
||
10 | { |
||
11 | /** @var array */ |
||
12 | private $fields = []; |
||
13 | /** @var array */ |
||
14 | private $formAttributes = []; |
||
15 | |||
16 | /** |
||
17 | * Formaggio constructor. |
||
18 | * @param string $action |
||
19 | * @param string $method |
||
20 | * @param array $attributes |
||
21 | */ |
||
22 | 7 | public function __construct($action = "/", $method = "post", $attributes = []) |
|
28 | |||
29 | /** |
||
30 | * @param $attributes |
||
31 | * @return array |
||
32 | */ |
||
33 | 7 | private function clearAttributesForm($attributes): array |
|
38 | |||
39 | /** |
||
40 | * @param int $index |
||
41 | * @return mixed|null |
||
42 | */ |
||
43 | 7 | public function getField($index = 0) |
|
47 | |||
48 | public function render() |
||
52 | |||
53 | /** |
||
54 | * @return string |
||
55 | */ |
||
56 | public function get(): string |
||
60 | |||
61 | /** |
||
62 | * @param array $attributes |
||
63 | * @return string |
||
64 | */ |
||
65 | private function getFormRendered($attributes = []) |
||
72 | |||
73 | /** |
||
74 | * @param $attributes |
||
75 | * @return string |
||
76 | */ |
||
77 | private function buildAttributes($attributes) |
||
85 | |||
86 | /** |
||
87 | * @param $fields |
||
88 | * @return string |
||
89 | */ |
||
90 | private function getFieldsRendered($fields) |
||
98 | |||
99 | /** |
||
100 | * @param $field |
||
101 | * @param string $tag |
||
102 | * @return string |
||
103 | */ |
||
104 | private function getFieldRendered($field, $tag = 'input') |
||
108 | |||
109 | /** |
||
110 | * @param string $name |
||
111 | * @param array $attributes |
||
112 | * @return $this |
||
113 | */ |
||
114 | 3 | public function text($name = "text", $attributes = array()) |
|
119 | |||
120 | 7 | private function addFieldByType($type, $name, $attributes) |
|
130 | |||
131 | /** |
||
132 | * @param $attributes |
||
133 | * @return mixed |
||
134 | */ |
||
135 | 7 | private function clearAttributesInput($attributes) |
|
140 | |||
141 | /** |
||
142 | * @param string $name |
||
143 | * @param array $attributes |
||
144 | * @return $this |
||
145 | */ |
||
146 | 2 | public function email($name = "email", $attributes = array()) |
|
151 | |||
152 | /** |
||
153 | * @param string $name |
||
154 | * @param array $attributes |
||
155 | * @return $this |
||
156 | */ |
||
157 | 2 | public function password($name = "password", $attributes = array()) |
|
162 | |||
163 | /** |
||
164 | * @param $placeholder |
||
165 | * @return $this |
||
166 | */ |
||
167 | 1 | public function place($placeholder) |
|
172 | } |