diff --git a/src/Symfony/Component/Form/SubmitButton.php b/src/Symfony/Component/Form/SubmitButton.php index ae69e0426d..2422e11cd8 100644 --- a/src/Symfony/Component/Form/SubmitButton.php +++ b/src/Symfony/Component/Form/SubmitButton.php @@ -43,6 +43,12 @@ class SubmitButton extends Button implements ClickableInterface */ public function submit($submittedData, $clearMissing = true) { + if ($this->getConfig()->getDisabled()) { + $this->clicked = false; + + return $this; + } + parent::submit($submittedData, $clearMissing); $this->clicked = null !== $submittedData; diff --git a/src/Symfony/Component/Form/Tests/CompoundFormTest.php b/src/Symfony/Component/Form/Tests/CompoundFormTest.php index 5f638b68fe..7975570ccc 100644 --- a/src/Symfony/Component/Form/Tests/CompoundFormTest.php +++ b/src/Symfony/Component/Form/Tests/CompoundFormTest.php @@ -1066,6 +1066,28 @@ class CompoundFormTest extends AbstractFormTest $this->assertSame($button, $this->form->getClickedButton()); } + public function testDisabledButtonIsNotSubmitted() + { + $button = new SubmitButtonBuilder('submit'); + $submit = $button + ->setDisabled(true) + ->getForm(); + + $form = $this->createForm() + ->add($this->getBuilder('text')->getForm()) + ->add($submit) + ; + + $form->submit(array( + 'text' => '', + 'submit' => '', + )); + + $this->assertTrue($submit->isDisabled()); + $this->assertFalse($submit->isClicked()); + $this->assertFalse($submit->isSubmitted()); + } + protected function createForm() { return $this->getBuilder()