SubmitButton.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  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 button that submits the form.
  13. *
  14. * @author Bernhard Schussek <bschussek@gmail.com>
  15. */
  16. class SubmitButton extends Button implements ClickableInterface
  17. {
  18. /**
  19. * @var bool
  20. */
  21. private $clicked = false;
  22. /**
  23. * {@inheritdoc}
  24. */
  25. public function isClicked()
  26. {
  27. return $this->clicked;
  28. }
  29. /**
  30. * Submits data to the button.
  31. *
  32. * @param string|null $submittedData The data
  33. * @param bool $clearMissing Not used
  34. *
  35. * @return $this
  36. *
  37. * @throws Exception\AlreadySubmittedException if the form has already been submitted
  38. */
  39. public function submit($submittedData, $clearMissing = true)
  40. {
  41. if ($this->getConfig()->getDisabled()) {
  42. $this->clicked = false;
  43. return $this;
  44. }
  45. parent::submit($submittedData, $clearMissing);
  46. $this->clicked = null !== $submittedData;
  47. return $this;
  48. }
  49. }