FormFactoryInterface.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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. /**
  12. * @author Bernhard Schussek <bschussek@gmail.com>
  13. */
  14. interface FormFactoryInterface
  15. {
  16. /**
  17. * Returns a form.
  18. *
  19. * @see createBuilder()
  20. *
  21. * @param string|FormTypeInterface $type The type of the form
  22. * @param mixed $data The initial data
  23. * @param array $options The options
  24. *
  25. * @return FormInterface The form named after the type
  26. *
  27. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
  28. */
  29. public function create($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array());
  30. /**
  31. * Returns a form.
  32. *
  33. * @see createNamedBuilder()
  34. *
  35. * @param string|int $name The name of the form
  36. * @param string|FormTypeInterface $type The type of the form
  37. * @param mixed $data The initial data
  38. * @param array $options The options
  39. *
  40. * @return FormInterface The form
  41. *
  42. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
  43. */
  44. public function createNamed($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array());
  45. /**
  46. * Returns a form for a property of a class.
  47. *
  48. * @see createBuilderForProperty()
  49. *
  50. * @param string $class The fully qualified class name
  51. * @param string $property The name of the property to guess for
  52. * @param mixed $data The initial data
  53. * @param array $options The options for the builder
  54. *
  55. * @return FormInterface The form named after the property
  56. *
  57. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the form type
  58. */
  59. public function createForProperty($class, $property, $data = null, array $options = array());
  60. /**
  61. * Returns a form builder.
  62. *
  63. * @param string|FormTypeInterface $type The type of the form
  64. * @param mixed $data The initial data
  65. * @param array $options The options
  66. *
  67. * @return FormBuilderInterface The form builder
  68. *
  69. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
  70. */
  71. public function createBuilder($type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array());
  72. /**
  73. * Returns a form builder.
  74. *
  75. * @param string|int $name The name of the form
  76. * @param string|FormTypeInterface $type The type of the form
  77. * @param mixed $data The initial data
  78. * @param array $options The options
  79. *
  80. * @return FormBuilderInterface The form builder
  81. *
  82. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the given type
  83. */
  84. public function createNamedBuilder($name, $type = 'Symfony\Component\Form\Extension\Core\Type\FormType', $data = null, array $options = array());
  85. /**
  86. * Returns a form builder for a property of a class.
  87. *
  88. * If any of the 'max_length', 'required' and type options can be guessed,
  89. * and are not provided in the options argument, the guessed value is used.
  90. *
  91. * @param string $class The fully qualified class name
  92. * @param string $property The name of the property to guess for
  93. * @param mixed $data The initial data
  94. * @param array $options The options for the builder
  95. *
  96. * @return FormBuilderInterface The form builder named after the property
  97. *
  98. * @throws \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException if any given option is not applicable to the form type
  99. */
  100. public function createBuilderForProperty($class, $property, $data = null, array $options = array());
  101. }