FormConfigBuilderInterface.php 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Component\Form;
  11. use Symfony\Component\EventDispatcher\EventSubscriberInterface;
  12. use Symfony\Component\PropertyAccess\PropertyPathInterface;
  13. /**
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. *
  16. * @method $this setIsEmptyCallback(callable|null $isEmptyCallback) Sets the callback that will be called to determine if the model data of the form is empty or not - not implementing it is deprecated since Symfony 5.1
  17. */
  18. interface FormConfigBuilderInterface extends FormConfigInterface
  19. {
  20. /**
  21. * Adds an event listener to an event on this form.
  22. *
  23. * @param int $priority The priority of the listener. Listeners
  24. * with a higher priority are called before
  25. * listeners with a lower priority.
  26. *
  27. * @return $this The configuration object
  28. */
  29. public function addEventListener(string $eventName, callable $listener, int $priority = 0);
  30. /**
  31. * Adds an event subscriber for events on this form.
  32. *
  33. * @return $this The configuration object
  34. */
  35. public function addEventSubscriber(EventSubscriberInterface $subscriber);
  36. /**
  37. * Appends / prepends a transformer to the view transformer chain.
  38. *
  39. * The transform method of the transformer is used to convert data from the
  40. * normalized to the view format.
  41. * The reverseTransform method of the transformer is used to convert from the
  42. * view to the normalized format.
  43. *
  44. * @param bool $forcePrepend If set to true, prepend instead of appending
  45. *
  46. * @return $this The configuration object
  47. */
  48. public function addViewTransformer(DataTransformerInterface $viewTransformer, bool $forcePrepend = false);
  49. /**
  50. * Clears the view transformers.
  51. *
  52. * @return $this The configuration object
  53. */
  54. public function resetViewTransformers();
  55. /**
  56. * Prepends / appends a transformer to the normalization transformer chain.
  57. *
  58. * The transform method of the transformer is used to convert data from the
  59. * model to the normalized format.
  60. * The reverseTransform method of the transformer is used to convert from the
  61. * normalized to the model format.
  62. *
  63. * @param bool $forceAppend If set to true, append instead of prepending
  64. *
  65. * @return $this The configuration object
  66. */
  67. public function addModelTransformer(DataTransformerInterface $modelTransformer, bool $forceAppend = false);
  68. /**
  69. * Clears the normalization transformers.
  70. *
  71. * @return $this The configuration object
  72. */
  73. public function resetModelTransformers();
  74. /**
  75. * Sets the value for an attribute.
  76. *
  77. * @param mixed $value The value of the attribute
  78. *
  79. * @return $this The configuration object
  80. */
  81. public function setAttribute(string $name, $value);
  82. /**
  83. * Sets the attributes.
  84. *
  85. * @return $this The configuration object
  86. */
  87. public function setAttributes(array $attributes);
  88. /**
  89. * Sets the data mapper used by the form.
  90. *
  91. * @return $this The configuration object
  92. */
  93. public function setDataMapper(DataMapperInterface $dataMapper = null);
  94. /**
  95. * Sets whether the form is disabled.
  96. *
  97. * @return $this The configuration object
  98. */
  99. public function setDisabled(bool $disabled);
  100. /**
  101. * Sets the data used for the client data when no value is submitted.
  102. *
  103. * @param mixed $emptyData The empty data
  104. *
  105. * @return $this The configuration object
  106. */
  107. public function setEmptyData($emptyData);
  108. /**
  109. * Sets whether errors bubble up to the parent.
  110. *
  111. * @return $this The configuration object
  112. */
  113. public function setErrorBubbling(bool $errorBubbling);
  114. /**
  115. * Sets whether this field is required to be filled out when submitted.
  116. *
  117. * @return $this The configuration object
  118. */
  119. public function setRequired(bool $required);
  120. /**
  121. * Sets the property path that the form should be mapped to.
  122. *
  123. * @param string|PropertyPathInterface|null $propertyPath The property path or null if the path should be set
  124. * automatically based on the form's name
  125. *
  126. * @return $this The configuration object
  127. */
  128. public function setPropertyPath($propertyPath);
  129. /**
  130. * Sets whether the form should be mapped to an element of its
  131. * parent's data.
  132. *
  133. * @return $this The configuration object
  134. */
  135. public function setMapped(bool $mapped);
  136. /**
  137. * Sets whether the form's data should be modified by reference.
  138. *
  139. * @return $this The configuration object
  140. */
  141. public function setByReference(bool $byReference);
  142. /**
  143. * Sets whether the form should read and write the data of its parent.
  144. *
  145. * @return $this The configuration object
  146. */
  147. public function setInheritData(bool $inheritData);
  148. /**
  149. * Sets whether the form should be compound.
  150. *
  151. * @return $this The configuration object
  152. *
  153. * @see FormConfigInterface::getCompound()
  154. */
  155. public function setCompound(bool $compound);
  156. /**
  157. * Sets the resolved type.
  158. *
  159. * @return $this The configuration object
  160. */
  161. public function setType(ResolvedFormTypeInterface $type);
  162. /**
  163. * Sets the initial data of the form.
  164. *
  165. * @param mixed $data The data of the form in model format
  166. *
  167. * @return $this The configuration object
  168. */
  169. public function setData($data);
  170. /**
  171. * Locks the form's data to the data passed in the configuration.
  172. *
  173. * A form with locked data is restricted to the data passed in
  174. * this configuration. The data can only be modified then by
  175. * submitting the form or using PRE_SET_DATA event.
  176. *
  177. * It means data passed to a factory method or mapped from the
  178. * parent will be ignored.
  179. *
  180. * @return $this The configuration object
  181. */
  182. public function setDataLocked(bool $locked);
  183. /**
  184. * Sets the form factory used for creating new forms.
  185. */
  186. public function setFormFactory(FormFactoryInterface $formFactory);
  187. /**
  188. * Sets the target URL of the form.
  189. *
  190. * @return $this The configuration object
  191. */
  192. public function setAction(string $action);
  193. /**
  194. * Sets the HTTP method used by the form.
  195. *
  196. * @return $this The configuration object
  197. */
  198. public function setMethod(string $method);
  199. /**
  200. * Sets the request handler used by the form.
  201. *
  202. * @return $this The configuration object
  203. */
  204. public function setRequestHandler(RequestHandlerInterface $requestHandler);
  205. /**
  206. * Sets whether the form should be initialized automatically.
  207. *
  208. * Should be set to true only for root forms.
  209. *
  210. * @param bool $initialize True to initialize the form automatically,
  211. * false to suppress automatic initialization.
  212. * In the second case, you need to call
  213. * {@link FormInterface::initialize()} manually.
  214. *
  215. * @return $this The configuration object
  216. */
  217. public function setAutoInitialize(bool $initialize);
  218. /**
  219. * Builds and returns the form configuration.
  220. *
  221. * @return FormConfigInterface
  222. */
  223. public function getFormConfig();
  224. }