FieldInterface.php 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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. * A form field that can be embedded in a form.
  13. *
  14. * @author Bernhard Schussek <bernhard.schussek@symfony.com>
  15. */
  16. interface FieldInterface
  17. {
  18. /**
  19. * Sets the parent field.
  20. *
  21. * @param FieldInterface $parent The parent field
  22. */
  23. function setParent(FieldInterface $parent = null);
  24. /**
  25. * Returns the parent field.
  26. *
  27. * @return FieldInterface The parent field
  28. */
  29. function getParent();
  30. /**
  31. * Returns the name by which the field is identified in forms.
  32. *
  33. * @return string The name of the field.
  34. */
  35. function getName();
  36. /**
  37. * Adds an error to this field
  38. *
  39. * @param Error $error
  40. */
  41. function addError(Error $error);
  42. /**
  43. * Returns whether the field is valid.
  44. *
  45. * @return Boolean
  46. */
  47. function isValid();
  48. /**
  49. * Returns whether the field is required to be filled out.
  50. *
  51. * If the field has a parent and the parent is not required, this method
  52. * will always return false. Otherwise the value set with setRequired()
  53. * is returned.
  54. *
  55. * @return Boolean
  56. */
  57. function isRequired();
  58. /**
  59. * Returns whether this field is disabled
  60. *
  61. * The content of a disabled field is displayed, but not allowed to be
  62. * modified. The validation of modified, disabled fields should fail.
  63. *
  64. * Fields whose parents are disabled are considered disabled regardless of
  65. * their own state.
  66. *
  67. * @return Boolean
  68. */
  69. function isDisabled();
  70. /**
  71. * Returns whether the field is empty
  72. *
  73. * @return boolean
  74. */
  75. function isEmpty();
  76. /**
  77. * Writes posted data into the field
  78. *
  79. * @param mixed $data The data from the POST request
  80. */
  81. function bind($data);
  82. }