Fixed submitting disabled buttons
This commit is contained in:
parent
1b92f0685d
commit
804b2a1a47
@ -43,6 +43,12 @@ class SubmitButton extends Button implements ClickableInterface
|
|||||||
*/
|
*/
|
||||||
public function submit($submittedData, $clearMissing = true)
|
public function submit($submittedData, $clearMissing = true)
|
||||||
{
|
{
|
||||||
|
if ($this->getConfig()->getDisabled()) {
|
||||||
|
$this->clicked = false;
|
||||||
|
|
||||||
|
return $this;
|
||||||
|
}
|
||||||
|
|
||||||
parent::submit($submittedData, $clearMissing);
|
parent::submit($submittedData, $clearMissing);
|
||||||
|
|
||||||
$this->clicked = null !== $submittedData;
|
$this->clicked = null !== $submittedData;
|
||||||
|
@ -1066,6 +1066,28 @@ class CompoundFormTest extends AbstractFormTest
|
|||||||
$this->assertSame($button, $this->form->getClickedButton());
|
$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()
|
protected function createForm()
|
||||||
{
|
{
|
||||||
return $this->getBuilder()
|
return $this->getBuilder()
|
||||||
|
Reference in New Issue
Block a user