|
1 <?php |
|
2 |
|
3 /* |
|
4 * This file is part of the Symfony package. |
|
5 * |
|
6 * (c) Fabien Potencier <fabien@symfony.com> |
|
7 * |
|
8 * For the full copyright and license information, please view the LICENSE |
|
9 * file that was distributed with this source code. |
|
10 */ |
|
11 |
|
12 namespace Symfony\Component\Form; |
|
13 |
|
14 /** |
|
15 * A form group bundling multiple form forms |
|
16 * |
|
17 * @author Bernhard Schussek <bernhard.schussek@symfony.com> |
|
18 */ |
|
19 interface FormInterface extends \ArrayAccess, \Traversable, \Countable |
|
20 { |
|
21 /** |
|
22 * Sets the parent form. |
|
23 * |
|
24 * @param FormInterface $parent The parent form |
|
25 */ |
|
26 function setParent(FormInterface $parent = null); |
|
27 |
|
28 /** |
|
29 * Returns the parent form. |
|
30 * |
|
31 * @return FormInterface The parent form |
|
32 */ |
|
33 function getParent(); |
|
34 |
|
35 /** |
|
36 * Returns whether the form has a parent. |
|
37 * |
|
38 * @return Boolean |
|
39 */ |
|
40 function hasParent(); |
|
41 |
|
42 /** |
|
43 * Adds a child to the form. |
|
44 * |
|
45 * @param FormInterface $child The FormInterface to add as a child |
|
46 */ |
|
47 function add(FormInterface $child); |
|
48 |
|
49 /** |
|
50 * Returns whether a child with the given name exists. |
|
51 * |
|
52 * @param string $name |
|
53 * |
|
54 * @return Boolean |
|
55 */ |
|
56 function has($name); |
|
57 |
|
58 /** |
|
59 * Removes a child from the form. |
|
60 * |
|
61 * @param string $name The name of the child to remove |
|
62 */ |
|
63 function remove($name); |
|
64 |
|
65 /** |
|
66 * Returns all children in this group. |
|
67 * |
|
68 * @return array An array of FormInterface instances |
|
69 */ |
|
70 function getChildren(); |
|
71 |
|
72 /** |
|
73 * Return whether the form has children. |
|
74 * |
|
75 * @return Boolean |
|
76 */ |
|
77 function hasChildren(); |
|
78 |
|
79 /** |
|
80 * Returns all errors. |
|
81 * |
|
82 * @return array An array of FormError instances that occurred during binding |
|
83 */ |
|
84 function getErrors(); |
|
85 |
|
86 /** |
|
87 * Updates the field with default data. |
|
88 * |
|
89 * @param array $appData The data formatted as expected for the underlying object |
|
90 * |
|
91 * @return Form The current form |
|
92 */ |
|
93 function setData($appData); |
|
94 |
|
95 /** |
|
96 * Returns the data in the format needed for the underlying object. |
|
97 * |
|
98 * @return mixed |
|
99 */ |
|
100 function getData(); |
|
101 |
|
102 /** |
|
103 * Returns the normalized data of the field. |
|
104 * |
|
105 * @return mixed When the field is not bound, the default data is returned. |
|
106 * When the field is bound, the normalized bound data is |
|
107 * returned if the field is valid, null otherwise. |
|
108 */ |
|
109 function getNormData(); |
|
110 |
|
111 /** |
|
112 * Returns the data transformed by the value transformer. |
|
113 * |
|
114 * @return string |
|
115 */ |
|
116 function getClientData(); |
|
117 |
|
118 /** |
|
119 * Returns the extra data. |
|
120 * |
|
121 * @return array The bound data which do not belong to a child |
|
122 */ |
|
123 function getExtraData(); |
|
124 |
|
125 /** |
|
126 * Returns whether the field is bound. |
|
127 * |
|
128 * @return Boolean true if the form is bound to input values, false otherwise |
|
129 */ |
|
130 function isBound(); |
|
131 |
|
132 /** |
|
133 * Returns the supported types. |
|
134 * |
|
135 * @return array An array of FormTypeInterface |
|
136 */ |
|
137 function getTypes(); |
|
138 |
|
139 /** |
|
140 * Returns the name by which the form is identified in forms. |
|
141 * |
|
142 * @return string The name of the form. |
|
143 */ |
|
144 function getName(); |
|
145 |
|
146 /** |
|
147 * Adds an error to this form. |
|
148 * |
|
149 * @param FormError $error |
|
150 */ |
|
151 function addError(FormError $error); |
|
152 |
|
153 /** |
|
154 * Returns whether the form is valid. |
|
155 * |
|
156 * @return Boolean |
|
157 */ |
|
158 function isValid(); |
|
159 |
|
160 /** |
|
161 * Returns whether the form is required to be filled out. |
|
162 * |
|
163 * If the form has a parent and the parent is not required, this method |
|
164 * will always return false. Otherwise the value set with setRequired() |
|
165 * is returned. |
|
166 * |
|
167 * @return Boolean |
|
168 */ |
|
169 function isRequired(); |
|
170 |
|
171 /** |
|
172 * Returns whether this form can be read only. |
|
173 * |
|
174 * The content of a read-only form is displayed, but not allowed to be |
|
175 * modified. The validation of modified read-only forms should fail. |
|
176 * |
|
177 * Fields whose parents are read-only are considered read-only regardless of |
|
178 * their own state. |
|
179 * |
|
180 * @return Boolean |
|
181 */ |
|
182 function isReadOnly(); |
|
183 |
|
184 /** |
|
185 * Returns whether the form is empty. |
|
186 * |
|
187 * @return Boolean |
|
188 */ |
|
189 function isEmpty(); |
|
190 |
|
191 /** |
|
192 * Returns whether the data in the different formats is synchronized. |
|
193 * |
|
194 * @return Boolean |
|
195 */ |
|
196 function isSynchronized(); |
|
197 |
|
198 /** |
|
199 * Writes data into the form. |
|
200 * |
|
201 * @param mixed $data The data |
|
202 */ |
|
203 function bind($data); |
|
204 |
|
205 /** |
|
206 * Returns whether the form has an attribute with the given name. |
|
207 * |
|
208 * @param string $name The name of the attribute |
|
209 */ |
|
210 function hasAttribute($name); |
|
211 |
|
212 /** |
|
213 * Returns the value of the attributes with the given name. |
|
214 * |
|
215 * @param string $name The name of the attribute |
|
216 */ |
|
217 function getAttribute($name); |
|
218 |
|
219 /** |
|
220 * Returns the root of the form tree. |
|
221 * |
|
222 * @return FormInterface The root of the tree |
|
223 */ |
|
224 function getRoot(); |
|
225 |
|
226 /** |
|
227 * Returns whether the field is the root of the form tree. |
|
228 * |
|
229 * @return Boolean |
|
230 */ |
|
231 function isRoot(); |
|
232 |
|
233 /** |
|
234 * Creates a view. |
|
235 * |
|
236 * @param FormView $parent The parent view |
|
237 * |
|
238 * @return FormView The view |
|
239 */ |
|
240 function createView(FormView $parent = null); |
|
241 } |