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
;
14 use Symfony\Component\EventDispatcher\EventSubscriberInterface
;
17 * @author Bernhard Schussek <bschussek@gmail.com>
19 interface FormConfigBuilderInterface
extends FormConfigInterface
22 * Adds an event listener to an event on this form.
24 * @param string $eventName The name of the event to listen to.
25 * @param callable $listener The listener to execute.
26 * @param integer $priority The priority of the listener. Listeners
27 * with a higher priority are called before
28 * listeners with a lower priority.
30 * @return self The configuration object.
32 public function addEventListener($eventName, $listener, $priority = 0);
35 * Adds an event subscriber for events on this form.
37 * @param EventSubscriberInterface $subscriber The subscriber to attach.
39 * @return self The configuration object.
41 public function addEventSubscriber(EventSubscriberInterface
$subscriber);
44 * Appends / prepends a transformer to the view transformer chain.
46 * The transform method of the transformer is used to convert data from the
47 * normalized to the view format.
48 * The reverseTransform method of the transformer is used to convert from the
49 * view to the normalized format.
51 * @param DataTransformerInterface $viewTransformer
52 * @param Boolean $forcePrepend if set to true, prepend instead of appending
54 * @return self The configuration object.
56 public function addViewTransformer(DataTransformerInterface
$viewTransformer, $forcePrepend = false);
59 * Clears the view transformers.
61 * @return self The configuration object.
63 public function resetViewTransformers();
66 * Prepends / appends a transformer to the normalization transformer chain.
68 * The transform method of the transformer is used to convert data from the
69 * model to the normalized format.
70 * The reverseTransform method of the transformer is used to convert from the
71 * normalized to the model format.
73 * @param DataTransformerInterface $modelTransformer
74 * @param Boolean $forceAppend if set to true, append instead of prepending
76 * @return self The configuration object.
78 public function addModelTransformer(DataTransformerInterface
$modelTransformer, $forceAppend = false);
81 * Clears the normalization transformers.
83 * @return self The configuration object.
85 public function resetModelTransformers();
88 * Sets the value for an attribute.
90 * @param string $name The name of the attribute
91 * @param string $value The value of the attribute
93 * @return self The configuration object.
95 public function setAttribute($name, $value);
98 * Sets the attributes.
100 * @param array $attributes The attributes.
102 * @return self The configuration object.
104 public function setAttributes(array $attributes);
107 * Sets the data mapper used by the form.
109 * @param DataMapperInterface $dataMapper
111 * @return self The configuration object.
113 public function setDataMapper(DataMapperInterface
$dataMapper = null);
116 * Set whether the form is disabled.
118 * @param Boolean $disabled Whether the form is disabled
120 * @return self The configuration object.
122 public function setDisabled($disabled);
125 * Sets the data used for the client data when no value is submitted.
127 * @param mixed $emptyData The empty data.
129 * @return self The configuration object.
131 public function setEmptyData($emptyData);
134 * Sets whether errors bubble up to the parent.
136 * @param Boolean $errorBubbling
138 * @return self The configuration object.
140 public function setErrorBubbling($errorBubbling);
143 * Sets whether this field is required to be filled out when submitted.
145 * @param Boolean $required
147 * @return self The configuration object.
149 public function setRequired($required);
152 * Sets the property path that the form should be mapped to.
154 * @param null|string|\Symfony\Component\PropertyAccess\PropertyPathInterface $propertyPath
155 * The property path or null if the path should be set
156 * automatically based on the form's name.
158 * @return self The configuration object.
160 public function setPropertyPath($propertyPath);
163 * Sets whether the form should be mapped to an element of its
166 * @param Boolean $mapped Whether the form should be mapped.
168 * @return self The configuration object.
170 public function setMapped($mapped);
173 * Sets whether the form's data should be modified by reference.
175 * @param Boolean $byReference Whether the data should be
176 * modified by reference.
178 * @return self The configuration object.
180 public function setByReference($byReference);
183 * Sets whether the form should read and write the data of its parent.
185 * @param Boolean $inheritData Whether the form should inherit its parent's data.
187 * @return self The configuration object.
189 public function setInheritData($inheritData);
192 * Sets whether the form should be compound.
194 * @param Boolean $compound Whether the form should be compound.
196 * @return self The configuration object.
198 * @see FormConfigInterface::getCompound()
200 public function setCompound($compound);
205 * @param ResolvedFormTypeInterface $type The type of the form.
207 * @return self The configuration object.
209 public function setType(ResolvedFormTypeInterface
$type);
212 * Sets the initial data of the form.
214 * @param array $data The data of the form in application format.
216 * @return self The configuration object.
218 public function setData($data);
221 * Locks the form's data to the data passed in the configuration.
223 * A form with locked data is restricted to the data passed in
224 * this configuration. The data can only be modified then by
225 * submitting the form.
227 * @param Boolean $locked Whether to lock the default data.
229 * @return self The configuration object.
231 public function setDataLocked($locked);
234 * Sets the form factory used for creating new forms.
236 * @param FormFactoryInterface $formFactory The form factory.
238 public function setFormFactory(FormFactoryInterface
$formFactory);
241 * Sets the target URL of the form.
243 * @param string $action The target URL of the form.
245 * @return self The configuration object.
247 public function setAction($action);
250 * Sets the HTTP method used by the form.
252 * @param string $method The HTTP method of the form.
254 * @return self The configuration object.
256 public function setMethod($method);
259 * Sets the request handler used by the form.
261 * @param RequestHandlerInterface $requestHandler
263 * @return self The configuration object.
265 public function setRequestHandler(RequestHandlerInterface
$requestHandler);
268 * Sets whether the form should be initialized automatically.
270 * Should be set to true only for root forms.
272 * @param Boolean $initialize True to initialize the form automatically,
273 * false to suppress automatic initialization.
274 * In the second case, you need to call
275 * {@link FormInterface::initialize()} manually.
277 * @return self The configuration object.
279 public function setAutoInitialize($initialize);
282 * Builds and returns the form configuration.
284 * @return FormConfigInterface
286 public function getFormConfig();