FormBuilderInterface.php 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 FormBuilderInterface extends \Traversable, \Countable, FormConfigBuilderInterface
  15. {
  16. /**
  17. * Adds a new field to this group. A field must have a unique name within
  18. * the group. Otherwise the existing field is overwritten.
  19. *
  20. * If you add a nested group, this group should also be represented in the
  21. * object hierarchy.
  22. *
  23. * @param string|FormBuilderInterface $child
  24. *
  25. * @return self
  26. */
  27. public function add($child, string $type = null, array $options = []);
  28. /**
  29. * Creates a form builder.
  30. *
  31. * @param string $name The name of the form or the name of the property
  32. * @param string|null $type The type of the form or null if name is a property
  33. *
  34. * @return self
  35. */
  36. public function create(string $name, string $type = null, array $options = []);
  37. /**
  38. * Returns a child by name.
  39. *
  40. * @return self
  41. *
  42. * @throws Exception\InvalidArgumentException if the given child does not exist
  43. */
  44. public function get(string $name);
  45. /**
  46. * Removes the field with the given name.
  47. *
  48. * @return self
  49. */
  50. public function remove(string $name);
  51. /**
  52. * Returns whether a field with the given name exists.
  53. *
  54. * @return bool
  55. */
  56. public function has(string $name);
  57. /**
  58. * Returns the children.
  59. *
  60. * @return array
  61. */
  62. public function all();
  63. /**
  64. * Creates the form.
  65. *
  66. * @return FormInterface The form
  67. */
  68. public function getForm();
  69. }