@@ -15,6 +15,8 @@ import {composeAsyncValidators, composeValidators, setUpControl, setUpControlGro
1515export const formDirectiveProvider : any =
1616 /*@ts 2dart_const*/ { provide : ControlContainer , useExisting : forwardRef ( ( ) => NgForm ) } ;
1717
18+ let _formWarningDisplayed : boolean = false ;
19+
1820/**
1921 * If `NgForm` is bound in a component, `<form>` elements in that component will be
2022 * upgraded to use the Angular form system.
@@ -76,6 +78,7 @@ export const formDirectiveProvider: any =
7678 *
7779 * @experimental
7880 */
81+
7982@Directive ( {
8083 selector : 'form:not([ngNoForm]):not([ngFormModel]),ngForm,[ngForm]' ,
8184 providers : [ formDirectiveProvider ] ,
@@ -95,13 +98,21 @@ export class NgForm extends ControlContainer implements Form {
9598 @Optional ( ) @Self ( ) @Inject ( NG_VALIDATORS ) validators : any [ ] ,
9699 @Optional ( ) @Self ( ) @Inject ( NG_ASYNC_VALIDATORS ) asyncValidators : any [ ] ) {
97100 super ( ) ;
98- console . warn ( `
101+ this . _displayWarning ( ) ;
102+ this . form = new ControlGroup (
103+ { } , null , composeValidators ( validators ) , composeAsyncValidators ( asyncValidators ) ) ;
104+ }
105+
106+ private _displayWarning ( ) {
107+ // TODO(kara): Update this when the new forms module becomes the default
108+ if ( ! _formWarningDisplayed ) {
109+ _formWarningDisplayed = true ;
110+ console . warn ( `
99111 *It looks like you're using the old forms module. This will be opt-in in the next RC, and
100112 will eventually be removed in favor of the new forms module. For more information, see:
101113 https://docs.google.com/document/u/1/d/1RIezQqE4aEhBRmArIAS1mRIZtWFf6JxN_7B4meyWK0Y/pub
102114 ` ) ;
103- this . form = new ControlGroup (
104- { } , null , composeValidators ( validators ) , composeAsyncValidators ( asyncValidators ) ) ;
115+ }
105116 }
106117
107118 get submitted ( ) : boolean { return this . _submitted ; }
0 commit comments