@@ -505,10 +505,27 @@ public function submit($submittedData, bool $clearMissing = true)
505
505
// they are collectable during submission only
506
506
$ this ->errors = [];
507
507
508
+ $ dispatcher = $ this ->config ->getEventDispatcher ();
509
+
508
510
// Obviously, a disabled form should not change its data upon submission.
509
- if ($ this ->isDisabled ()) {
511
+ if ($ this ->isDisabled () && $ this -> isRoot () ) {
510
512
$ this ->submitted = true ;
511
513
514
+ if ($ dispatcher ->hasListeners (FormEvents::PRE_SUBMIT )) {
515
+ $ event = new FormEvent ($ this , $ submittedData );
516
+ $ dispatcher ->dispatch (FormEvents::PRE_SUBMIT , $ event );
517
+ }
518
+
519
+ if ($ dispatcher ->hasListeners (FormEvents::SUBMIT )) {
520
+ $ event = new FormEvent ($ this , $ this ->getNormData ());
521
+ $ dispatcher ->dispatch (FormEvents::SUBMIT , $ event );
522
+ }
523
+
524
+ if ($ dispatcher ->hasListeners (FormEvents::POST_SUBMIT )) {
525
+ $ event = new FormEvent ($ this , $ this ->getViewData ());
526
+ $ dispatcher ->dispatch (FormEvents::POST_SUBMIT , $ event );
527
+ }
528
+
512
529
return $ this ;
513
530
}
514
531
@@ -538,8 +555,6 @@ public function submit($submittedData, bool $clearMissing = true)
538
555
$ this ->transformationFailure = new TransformationFailedException ('Submitted data was expected to be text or number, array given. ' );
539
556
}
540
557
541
- $ dispatcher = $ this ->config ->getEventDispatcher ();
542
-
543
558
$ modelData = null ;
544
559
$ normData = null ;
545
560
$ viewData = null ;
@@ -752,10 +767,6 @@ public function isValid()
752
767
throw new LogicException ('Cannot check if an unsubmitted form is valid. Call Form::isSubmitted() before Form::isValid(). ' );
753
768
}
754
769
755
- if ($ this ->isDisabled ()) {
756
- return true ;
757
- }
758
-
759
770
return 0 === \count ($ this ->getErrors (true ));
760
771
}
761
772
0 commit comments