This repository was archived by the owner on Apr 12, 2024. It is now read-only.
File tree 2 files changed +33
-1
lines changed
2 files changed +33
-1
lines changed Original file line number Diff line number Diff line change @@ -280,7 +280,7 @@ FormController.prototype = {
280
280
}
281
281
282
282
forEach ( this . $$controls , function ( control ) {
283
- if ( control . $setSubmitted ) {
283
+ if ( control . $setSubmitted && ! control . $submitted ) {
284
284
control . $setSubmitted ( true ) ;
285
285
}
286
286
} ) ;
Original file line number Diff line number Diff line change @@ -541,9 +541,41 @@ describe('form', function() {
541
541
child = scope . child ;
542
542
543
543
parent . $setSubmitted ( ) ;
544
+ expect ( parent . $submitted ) . toBeTruthy ( ) ;
544
545
expect ( child . $submitted ) . toBeTruthy ( ) ;
545
546
} ) ;
546
547
548
+ it ( 'should set $submitted to true on child and parent forms when form is submitted' , function ( ) {
549
+ doc = jqLite (
550
+ '<ng-form name="parent">' +
551
+ '<ng-form name="child">' +
552
+ '<ng-form name="grandchild">' +
553
+ '<input ng:model="modelA" name="inputA">' +
554
+ '<input ng:model="modelB" name="inputB">' +
555
+ '</ng-form>' +
556
+ '</ng-form>' +
557
+ '</ng-form>' ) ;
558
+ $compile ( doc ) ( scope ) ;
559
+
560
+ var parent = scope . parent ,
561
+ child = scope . child ,
562
+ grandchild = scope . grandchild ;
563
+
564
+ spyOn ( parent , '$setSubmitted' ) . and . callThrough ( ) ;
565
+ spyOn ( child , '$setSubmitted' ) . and . callThrough ( ) ;
566
+ spyOn ( grandchild , '$setSubmitted' ) . and . callThrough ( ) ;
567
+
568
+ child . $setSubmitted ( ) ;
569
+
570
+ expect ( parent . $submitted ) . toBeTruthy ( ) ;
571
+ expect ( child . $submitted ) . toBeTruthy ( ) ;
572
+ expect ( grandchild . $submitted ) . toBeTruthy ( ) ;
573
+
574
+ expect ( parent . $setSubmitted ) . toHaveBeenCalledOnce ( ) ;
575
+ expect ( child . $setSubmitted ) . toHaveBeenCalledOnce ( ) ;
576
+ expect ( grandchild . $setSubmitted ) . toHaveBeenCalledOnce ( ) ;
577
+ } ) ;
578
+
547
579
it ( 'should deregister a child form when its DOM is removed' , function ( ) {
548
580
doc = jqLite (
549
581
'<form name="parent">' +
You can’t perform that action at this time.
0 commit comments