]>
git.immae.eu Git - github/wallabag/wallabag.git/blob - vendor/symfony/form/Symfony/Component/Form/FormInterface.php
4 * This file is part of the Symfony package.
6 * (c) Fabien Potencier <fabien@symfony.com>
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
12 namespace Symfony\Component\Form
;
15 * A form group bundling multiple forms in a hierarchical structure.
17 * @author Bernhard Schussek <bschussek@gmail.com>
19 interface FormInterface
extends \ArrayAccess
, \Traversable
, \Countable
22 * Sets the parent form.
24 * @param FormInterface|null $parent The parent form or null if it's the root.
26 * @return FormInterface The form instance
28 * @throws Exception\AlreadySubmittedException If the form has already been submitted.
29 * @throws Exception\LogicException When trying to set a parent for a form with
32 public function setParent(FormInterface
$parent = null);
35 * Returns the parent form.
37 * @return FormInterface|null The parent form or null if there is none.
39 public function getParent();
42 * Adds a child to the form.
44 * @param FormInterface|string|integer $child The FormInterface instance or the name of the child.
45 * @param string|null $type The child's type, if a name was passed.
46 * @param array $options The child's options, if a name was passed.
48 * @return FormInterface The form instance
50 * @throws Exception\AlreadySubmittedException If the form has already been submitted.
51 * @throws Exception\LogicException When trying to add a child to a non-compound form.
52 * @throws Exception\UnexpectedTypeException If $child or $type has an unexpected type.
54 public function add($child, $type = null, array $options = array());
57 * Returns the child with the given name.
59 * @param string $name The name of the child
61 * @return FormInterface The child form
63 * @throws \OutOfBoundsException If the named child does not exist.
65 public function get($name);
68 * Returns whether a child with the given name exists.
70 * @param string $name The name of the child
74 public function has($name);
77 * Removes a child from the form.
79 * @param string $name The name of the child to remove
81 * @return FormInterface The form instance
83 * @throws Exception\AlreadySubmittedException If the form has already been submitted.
85 public function remove($name);
88 * Returns all children in this group.
90 * @return FormInterface[] An array of FormInterface instances
92 public function all();
97 * @return FormError[] An array of FormError instances that occurred during validation
99 public function getErrors();
102 * Updates the form with default data.
104 * @param mixed $modelData The data formatted as expected for the underlying object
106 * @return FormInterface The form instance
108 * @throws Exception\AlreadySubmittedException If the form has already been submitted.
109 * @throws Exception\LogicException If listeners try to call setData in a cycle. Or if
110 * the view data does not match the expected type
111 * according to {@link FormConfigInterface::getDataClass}.
113 public function setData($modelData);
116 * Returns the data in the format needed for the underlying object.
120 public function getData();
123 * Returns the normalized data of the field.
125 * @return mixed When the field is not submitted, the default data is returned.
126 * When the field is submitted, the normalized submitted data is
127 * returned if the field is valid, null otherwise.
129 public function getNormData();
132 * Returns the data transformed by the value transformer.
136 public function getViewData();
139 * Returns the extra data.
141 * @return array The submitted data which do not belong to a child
143 public function getExtraData();
146 * Returns the form's configuration.
148 * @return FormConfigInterface The configuration.
150 public function getConfig();
153 * Returns whether the form is submitted.
155 * @return Boolean true if the form is submitted, false otherwise
157 public function isSubmitted();
160 * Returns the name by which the form is identified in forms.
162 * @return string The name of the form.
164 public function getName();
167 * Returns the property path that the form is mapped to.
169 * @return \Symfony\Component\PropertyAccess\PropertyPathInterface The property path.
171 public function getPropertyPath();
174 * Adds an error to this form.
176 * @param FormError $error
178 * @return FormInterface The form instance
180 public function addError(FormError
$error);
183 * Returns whether the form and all children are valid.
185 * If the form is not submitted, this method always returns false.
189 public function isValid();
192 * Returns whether the form is required to be filled out.
194 * If the form has a parent and the parent is not required, this method
195 * will always return false. Otherwise the value set with setRequired()
200 public function isRequired();
203 * Returns whether this form is disabled.
205 * The content of a disabled form is displayed, but not allowed to be
206 * modified. The validation of modified disabled forms should fail.
208 * Forms whose parents are disabled are considered disabled regardless of
213 public function isDisabled();
216 * Returns whether the form is empty.
220 public function isEmpty();
223 * Returns whether the data in the different formats is synchronized.
227 public function isSynchronized();
230 * Initializes the form tree.
232 * Should be called on the root form after constructing the tree.
234 * @return FormInterface The form instance.
236 public function initialize();
239 * Inspects the given request and calls {@link submit()} if the form was
242 * Internally, the request is forwarded to the configured
243 * {@link RequestHandlerInterface} instance, which determines whether to
244 * submit the form or not.
246 * @param mixed $request The request to handle.
248 * @return FormInterface The form instance.
250 public function handleRequest($request = null);
253 * Submits data to the form, transforms and validates it.
255 * @param null|string|array $submittedData The submitted data.
256 * @param Boolean $clearMissing Whether to set fields to NULL
257 * when they are missing in the
260 * @return FormInterface The form instance
262 * @throws Exception\AlreadySubmittedException If the form has already been submitted.
264 public function submit($submittedData, $clearMissing = true);
267 * Returns the root of the form tree.
269 * @return FormInterface The root of the tree
271 public function getRoot();
274 * Returns whether the field is the root of the form tree.
278 public function isRoot();
283 * @param FormView $parent The parent view
285 * @return FormView The view
287 public function createView(FormView
$parent = null);