Revert "feature #33381 [Form] dispatch submit events for disabled forms too (xabbuh)"
This reverts commitdc63d712ab
, reversing changes made to59ae592909
.
This commit is contained in:
parent
aa5d0ea829
commit
2e819f3ba9
@ -505,27 +505,10 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
|
|||||||
// they are collectable during submission only
|
// they are collectable during submission only
|
||||||
$this->errors = [];
|
$this->errors = [];
|
||||||
|
|
||||||
$dispatcher = $this->config->getEventDispatcher();
|
|
||||||
|
|
||||||
// Obviously, a disabled form should not change its data upon submission.
|
// Obviously, a disabled form should not change its data upon submission.
|
||||||
if ($this->isDisabled() && $this->isRoot()) {
|
if ($this->isDisabled()) {
|
||||||
$this->submitted = true;
|
$this->submitted = true;
|
||||||
|
|
||||||
if ($dispatcher->hasListeners(FormEvents::PRE_SUBMIT)) {
|
|
||||||
$event = new FormEvent($this, $submittedData);
|
|
||||||
$dispatcher->dispatch(FormEvents::PRE_SUBMIT, $event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($dispatcher->hasListeners(FormEvents::SUBMIT)) {
|
|
||||||
$event = new FormEvent($this, $this->getNormData());
|
|
||||||
$dispatcher->dispatch(FormEvents::SUBMIT, $event);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($dispatcher->hasListeners(FormEvents::POST_SUBMIT)) {
|
|
||||||
$event = new FormEvent($this, $this->getViewData());
|
|
||||||
$dispatcher->dispatch(FormEvents::POST_SUBMIT, $event);
|
|
||||||
}
|
|
||||||
|
|
||||||
return $this;
|
return $this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -555,6 +538,8 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
|
|||||||
$this->transformationFailure = new TransformationFailedException('Submitted data was expected to be text or number, array given.');
|
$this->transformationFailure = new TransformationFailedException('Submitted data was expected to be text or number, array given.');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$dispatcher = $this->config->getEventDispatcher();
|
||||||
|
|
||||||
$modelData = null;
|
$modelData = null;
|
||||||
$normData = null;
|
$normData = null;
|
||||||
$viewData = null;
|
$viewData = null;
|
||||||
@ -767,6 +752,10 @@ class Form implements \IteratorAggregate, FormInterface, ClearableErrorsInterfac
|
|||||||
throw new LogicException('Cannot check if an unsubmitted form is valid. Call Form::isSubmitted() before Form::isValid().');
|
throw new LogicException('Cannot check if an unsubmitted form is valid. Call Form::isSubmitted() before Form::isValid().');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ($this->isDisabled()) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
return 0 === \count($this->getErrors(true));
|
return 0 === \count($this->getErrors(true));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -55,7 +55,7 @@ class CompoundFormTest extends AbstractFormTest
|
|||||||
$this->assertFalse($this->form->isValid());
|
$this->assertFalse($this->form->isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testDisabledFormsInvalidEvenChildrenInvalid()
|
public function testDisabledFormsValidEvenIfChildrenInvalid()
|
||||||
{
|
{
|
||||||
$form = $this->getBuilder('person')
|
$form = $this->getBuilder('person')
|
||||||
->setDisabled(true)
|
->setDisabled(true)
|
||||||
@ -68,7 +68,7 @@ class CompoundFormTest extends AbstractFormTest
|
|||||||
|
|
||||||
$form->get('name')->addError(new FormError('Invalid'));
|
$form->get('name')->addError(new FormError('Invalid'));
|
||||||
|
|
||||||
$this->assertFalse($form->isValid());
|
$this->assertTrue($form->isValid());
|
||||||
}
|
}
|
||||||
|
|
||||||
public function testSubmitForwardsNullIfNotClearMissingButValueIsExplicitlyNull()
|
public function testSubmitForwardsNullIfNotClearMissingButValueIsExplicitlyNull()
|
||||||
|
Reference in New Issue
Block a user