Skip to content

Commit

Permalink
feat(core): deprecate passing content inside the 'formly-form' tag (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
aitboudad committed Oct 9, 2019
1 parent 4607b1c commit 0f168f7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
15 changes: 15 additions & 0 deletions UPGRADE-5.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,21 @@ FormlyModule.forRoot({
})
```

* Passing content inside the 'formly-form' tag is deprecated.

Before:
```html
<formly-form>
<button>Submit</button>
</formly-form>
```

After:
```html
<formly-form></formly-form>
<button type="submit">Submit</button>
```

@ngx-formly/material
--------------------
**Note**: this only affect the user's who import sub-modules of `@ngx-formly/material` instead of main module `FormlyMaterialModule`.
Expand Down
11 changes: 9 additions & 2 deletions src/core/src/lib/components/formly.form.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, DoCheck, OnChanges, Input, SimpleChanges, Optional, EventEmitter, Output, OnDestroy, Attribute } from '@angular/core';
import { Component, DoCheck, OnChanges, Input, SimpleChanges, Optional, EventEmitter, Output, OnDestroy, Attribute, ViewChild, ElementRef } from '@angular/core';
import { FormGroup, FormArray, FormGroupDirective } from '@angular/forms';
import { FormlyFieldConfig, FormlyFormOptions, FormlyFormOptionsCache } from './formly.field.config';
import { FormlyFormBuilder } from '../services/formly.form.builder';
Expand All @@ -17,7 +17,9 @@ import { debounceTime } from 'rxjs/operators';
[model]="field.model"
[field]="field">
</formly-field>
<ng-content></ng-content>
<ng-container #content>
<ng-content></ng-content>
</ng-container>
`,
providers: [FormlyFormBuilder],
})
Expand All @@ -37,6 +39,11 @@ export class FormlyForm implements DoCheck, OnChanges, OnDestroy {
get options() { return this._options; }

@Output() modelChange = new EventEmitter<any>();
@ViewChild('content') set content(content: ElementRef<HTMLElement>) {
if (content.nativeElement.nextSibling) {
console.warn(`NgxFormly: content projection for 'formly-form' component is deprecated since v5.5, you should avoid passing content inside the 'formly-form' tag.`);
}
}

private immutable = false;
private _model: any;
Expand Down

0 comments on commit 0f168f7

Please sign in to comment.