FormConfigInterface.php 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250
  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\EventDispatcherInterface;
  12. use Symfony\Component\PropertyAccess\PropertyPathInterface;
  13. /**
  14. * The configuration of a {@link Form} object.
  15. *
  16. * @author Bernhard Schussek <bschussek@gmail.com>
  17. *
  18. * @method callable|null getIsEmptyCallback() Returns a callable that takes the model data as argument and that returns if it is empty or not - not implementing it is deprecated since Symfony 5.1
  19. */
  20. interface FormConfigInterface
  21. {
  22. /**
  23. * Returns the event dispatcher used to dispatch form events.
  24. *
  25. * @return EventDispatcherInterface The dispatcher
  26. */
  27. public function getEventDispatcher();
  28. /**
  29. * Returns the name of the form used as HTTP parameter.
  30. *
  31. * @return string The form name
  32. */
  33. public function getName();
  34. /**
  35. * Returns the property path that the form should be mapped to.
  36. *
  37. * @return PropertyPathInterface|null The property path
  38. */
  39. public function getPropertyPath();
  40. /**
  41. * Returns whether the form should be mapped to an element of its
  42. * parent's data.
  43. *
  44. * @return bool Whether the form is mapped
  45. */
  46. public function getMapped();
  47. /**
  48. * Returns whether the form's data should be modified by reference.
  49. *
  50. * @return bool Whether to modify the form's data by reference
  51. */
  52. public function getByReference();
  53. /**
  54. * Returns whether the form should read and write the data of its parent.
  55. *
  56. * @return bool Whether the form should inherit its parent's data
  57. */
  58. public function getInheritData();
  59. /**
  60. * Returns whether the form is compound.
  61. *
  62. * This property is independent of whether the form actually has
  63. * children. A form can be compound and have no children at all, like
  64. * for example an empty collection form.
  65. * The contrary is not possible, a form which is not compound
  66. * cannot have any children.
  67. *
  68. * @return bool Whether the form is compound
  69. */
  70. public function getCompound();
  71. /**
  72. * Returns the resolved form type used to construct the form.
  73. *
  74. * @return ResolvedFormTypeInterface The form's resolved type
  75. */
  76. public function getType();
  77. /**
  78. * Returns the view transformers of the form.
  79. *
  80. * @return DataTransformerInterface[] An array of {@link DataTransformerInterface} instances
  81. */
  82. public function getViewTransformers();
  83. /**
  84. * Returns the model transformers of the form.
  85. *
  86. * @return DataTransformerInterface[] An array of {@link DataTransformerInterface} instances
  87. */
  88. public function getModelTransformers();
  89. /**
  90. * Returns the data mapper of the compound form or null for a simple form.
  91. *
  92. * @return DataMapperInterface|null The data mapper
  93. */
  94. public function getDataMapper();
  95. /**
  96. * Returns whether the form is required.
  97. *
  98. * @return bool Whether the form is required
  99. */
  100. public function getRequired();
  101. /**
  102. * Returns whether the form is disabled.
  103. *
  104. * @return bool Whether the form is disabled
  105. */
  106. public function getDisabled();
  107. /**
  108. * Returns whether errors attached to the form will bubble to its parent.
  109. *
  110. * @return bool Whether errors will bubble up
  111. */
  112. public function getErrorBubbling();
  113. /**
  114. * Used when the view data is empty on submission.
  115. *
  116. * When the form is compound it will also be used to map the
  117. * children data.
  118. *
  119. * The empty data must match the view format as it will passed to the first view transformer's
  120. * "reverseTransform" method.
  121. *
  122. * @return mixed The data used when the submitted form is initially empty
  123. */
  124. public function getEmptyData();
  125. /**
  126. * Returns additional attributes of the form.
  127. *
  128. * @return array An array of key-value combinations
  129. */
  130. public function getAttributes();
  131. /**
  132. * Returns whether the attribute with the given name exists.
  133. *
  134. * @return bool Whether the attribute exists
  135. */
  136. public function hasAttribute(string $name);
  137. /**
  138. * Returns the value of the given attribute.
  139. *
  140. * @param mixed $default The value returned if the attribute does not exist
  141. *
  142. * @return mixed The attribute value
  143. */
  144. public function getAttribute(string $name, $default = null);
  145. /**
  146. * Returns the initial data of the form.
  147. *
  148. * @return mixed The initial form data
  149. */
  150. public function getData();
  151. /**
  152. * Returns the class of the view data or null if the data is scalar or an array.
  153. *
  154. * @return string|null The data class or null
  155. */
  156. public function getDataClass();
  157. /**
  158. * Returns whether the form's data is locked.
  159. *
  160. * A form with locked data is restricted to the data passed in
  161. * this configuration. The data can only be modified then by
  162. * submitting the form.
  163. *
  164. * @return bool Whether the data is locked
  165. */
  166. public function getDataLocked();
  167. /**
  168. * Returns the form factory used for creating new forms.
  169. *
  170. * @return FormFactoryInterface The form factory
  171. */
  172. public function getFormFactory();
  173. /**
  174. * Returns the target URL of the form.
  175. *
  176. * @return string The target URL of the form
  177. */
  178. public function getAction();
  179. /**
  180. * Returns the HTTP method used by the form.
  181. *
  182. * @return string The HTTP method of the form
  183. */
  184. public function getMethod();
  185. /**
  186. * Returns the request handler used by the form.
  187. *
  188. * @return RequestHandlerInterface The request handler
  189. */
  190. public function getRequestHandler();
  191. /**
  192. * Returns whether the form should be initialized upon creation.
  193. *
  194. * @return bool returns true if the form should be initialized
  195. * when created, false otherwise
  196. */
  197. public function getAutoInitialize();
  198. /**
  199. * Returns all options passed during the construction of the form.
  200. *
  201. * @return array The passed options
  202. */
  203. public function getOptions();
  204. /**
  205. * Returns whether a specific option exists.
  206. *
  207. * @return bool Whether the option exists
  208. */
  209. public function hasOption(string $name);
  210. /**
  211. * Returns the value of a specific option.
  212. *
  213. * @param mixed $default The value returned if the option does not exist
  214. *
  215. * @return mixed The option value
  216. */
  217. public function getOption(string $name, $default = null);
  218. }