FormEvents.php 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110
  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\Form\Deprecated\FormEvents as Deprecated;
  12. /**
  13. * To learn more about how form events work check the documentation
  14. * entry at {@link https://symfony.com/doc/any/components/form/form_events.html}.
  15. *
  16. * To learn how to dynamically modify forms using events check the cookbook
  17. * entry at {@link https://symfony.com/doc/any/cookbook/form/dynamic_form_modification.html}.
  18. *
  19. * @author Bernhard Schussek <bschussek@gmail.com>
  20. */
  21. final class FormEvents
  22. {
  23. /**
  24. * The PRE_SUBMIT event is dispatched at the beginning of the Form::submit() method.
  25. *
  26. * It can be used to:
  27. * - Change data from the request, before submitting the data to the form.
  28. * - Add or remove form fields, before submitting the data to the form.
  29. * The event listener method receives a Symfony\Component\Form\FormEvent instance.
  30. *
  31. * @Event
  32. */
  33. const PRE_SUBMIT = 'form.pre_bind';
  34. /**
  35. * The SUBMIT event is dispatched just before the Form::submit() method
  36. * transforms back the normalized data to the model and view data.
  37. *
  38. * It can be used to change data from the normalized representation of the data.
  39. * The event listener method receives a Symfony\Component\Form\FormEvent instance.
  40. *
  41. * @Event
  42. */
  43. const SUBMIT = 'form.bind';
  44. /**
  45. * The FormEvents::POST_SUBMIT event is dispatched after the Form::submit()
  46. * once the model and view data have been denormalized.
  47. *
  48. * It can be used to fetch data after denormalization.
  49. * The event listener method receives a Symfony\Component\Form\FormEvent instance.
  50. *
  51. * @Event
  52. */
  53. const POST_SUBMIT = 'form.post_bind';
  54. /**
  55. * The FormEvents::PRE_SET_DATA event is dispatched at the beginning of the Form::setData() method.
  56. *
  57. * It can be used to:
  58. * - Modify the data given during pre-population;
  59. * - Modify a form depending on the pre-populated data (adding or removing fields dynamically).
  60. * The event listener method receives a Symfony\Component\Form\FormEvent instance.
  61. *
  62. * @Event
  63. */
  64. const PRE_SET_DATA = 'form.pre_set_data';
  65. /**
  66. * The FormEvents::POST_SET_DATA event is dispatched at the end of the Form::setData() method.
  67. *
  68. * This event is mostly here for reading data after having pre-populated the form.
  69. * The event listener method receives a Symfony\Component\Form\FormEvent instance.
  70. *
  71. * @Event
  72. */
  73. const POST_SET_DATA = 'form.post_set_data';
  74. /**
  75. * @deprecated since version 2.3, to be removed in 3.0.
  76. * Use {@link PRE_SUBMIT} instead.
  77. *
  78. * @Event
  79. */
  80. const PRE_BIND = Deprecated::PRE_BIND;
  81. /**
  82. * @deprecated since version 2.3, to be removed in 3.0.
  83. * Use {@link SUBMIT} instead.
  84. *
  85. * @Event
  86. */
  87. const BIND = Deprecated::BIND;
  88. /**
  89. * @deprecated since version 2.3, to be removed in 3.0.
  90. * Use {@link POST_SUBMIT} instead.
  91. *
  92. * @Event
  93. */
  94. const POST_BIND = Deprecated::POST_BIND;
  95. private function __construct()
  96. {
  97. }
  98. }