|
@@ -56,15 +56,22 @@ export class DynafieldDirective extends NgControl implements OnInit /* OnChanges
|
|
);
|
|
);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- const { name, class: cssClass, id: cssId } = this.meta;
|
|
|
|
|
|
+ const { name, class: cssClass, id: cssId, isDisabled } = this.meta;
|
|
|
|
+
|
|
|
|
+ // Create the component
|
|
const component = this.resolver.resolveComponentFactory<FFC>(formFieldComponents[type]);
|
|
const component = this.resolver.resolveComponentFactory<FFC>(formFieldComponents[type]);
|
|
this.component = this.container.createComponent(component);
|
|
this.component = this.container.createComponent(component);
|
|
const instance = this.component.instance;
|
|
const instance = this.component.instance;
|
|
const el = this.component.location.nativeElement;
|
|
const el = this.component.location.nativeElement;
|
|
|
|
|
|
- // Send in the data
|
|
|
|
|
|
+ // Set its FormControl and metadata
|
|
|
|
+ if (isDisabled) {
|
|
|
|
+ this.control.reset({ value: this.control.value, disabled: true });
|
|
|
|
+ }
|
|
instance.control = this.control;
|
|
instance.control = this.control;
|
|
instance.meta = this.meta;
|
|
instance.meta = this.meta;
|
|
|
|
+
|
|
|
|
+ // Add id and classes (if specified)
|
|
if (cssClass) {
|
|
if (cssClass) {
|
|
const classesToAdd = Array.isArray(cssClass) ? cssClass : [cssClass];
|
|
const classesToAdd = Array.isArray(cssClass) ? cssClass : [cssClass];
|
|
el.classList.add(...classesToAdd);
|
|
el.classList.add(...classesToAdd);
|
|
@@ -72,6 +79,8 @@ export class DynafieldDirective extends NgControl implements OnInit /* OnChanges
|
|
if (cssId) {
|
|
if (cssId) {
|
|
el.id = cssId;
|
|
el.id = cssId;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ // Connect custom components
|
|
if (instance.propagateChange) {
|
|
if (instance.propagateChange) {
|
|
// We're dealing with a custom form control which implements the ControlValueAccessor interface,
|
|
// We're dealing with a custom form control which implements the ControlValueAccessor interface,
|
|
// so we need to wire it up!
|
|
// so we need to wire it up!
|