bug #25927 [Form] Fixed submitting disabled buttons (HeahDude)
This PR was merged into the 2.7 branch.
Discussion
----------
[Form] Fixed submitting disabled buttons
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #23759
| License | MIT
| Doc PR | ~
Commits
-------
804b2a1a47
Fixed submitting disabled buttons
This commit is contained in:
commit
0cd675ca4a
@ -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