SubmitButton.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  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. private $clicked = false;
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function isClicked()
  23. {
  24. return $this->clicked;
  25. }
  26. /**
  27. * Submits data to the button.
  28. *
  29. * @param string|null $submittedData The data
  30. * @param bool $clearMissing Not used
  31. *
  32. * @return $this
  33. *
  34. * @throws Exception\AlreadySubmittedException if the form has already been submitted
  35. */
  36. public function submit($submittedData, bool $clearMissing = true)
  37. {
  38. if ($this->getConfig()->getDisabled()) {
  39. $this->clicked = false;
  40. return $this;
  41. }
  42. parent::submit($submittedData, $clearMissing);
  43. $this->clicked = null !== $submittedData;
  44. return $this;
  45. }
  46. }