|
@@ -7,7 +7,7 @@ import { Form, FormControl, ControlContainer, NgControl, ControlValueAccessor, V
|
|
import * as formFieldComponents from './../components';
|
|
import * as formFieldComponents from './../components';
|
|
|
|
|
|
interface FFC {
|
|
interface FFC {
|
|
- control: FormControl;
|
|
|
|
|
|
+ control: FormControl; // Remember, this can be an individual control or a FormGroup
|
|
meta: StringMap;
|
|
meta: StringMap;
|
|
propagateChange?: Function;
|
|
propagateChange?: Function;
|
|
}
|
|
}
|
|
@@ -56,7 +56,8 @@ export class DynafieldDirective extends NgControl implements OnInit {
|
|
);
|
|
);
|
|
}
|
|
}
|
|
try {
|
|
try {
|
|
- const { name, class: cssClass, id: cssId, isDisabled } = this.meta;
|
|
|
|
|
|
+ let { control, meta } = this;
|
|
|
|
+ const { name, class: cssClass, id: cssId, isDisabled } = meta;
|
|
|
|
|
|
// Create the component
|
|
// Create the component
|
|
const component = this.resolver.resolveComponentFactory<FFC>(formFieldComponents[type]);
|
|
const component = this.resolver.resolveComponentFactory<FFC>(formFieldComponents[type]);
|
|
@@ -65,12 +66,16 @@ export class DynafieldDirective extends NgControl implements OnInit {
|
|
const el = this.component.location.nativeElement;
|
|
const el = this.component.location.nativeElement;
|
|
el.classList.add(type.toLowerCase().replace('component', ''));
|
|
el.classList.add(type.toLowerCase().replace('component', ''));
|
|
|
|
|
|
|
|
+ if (type === 'DynaformComponent') {
|
|
|
|
+ meta = meta.meta;
|
|
|
|
+ }
|
|
|
|
+
|
|
// Check whether it's disabled, then set its FormControl and metadata
|
|
// Check whether it's disabled, then set its FormControl and metadata
|
|
if (isDisabled) {
|
|
if (isDisabled) {
|
|
this.control.reset({ value: this.control.value, disabled: true });
|
|
this.control.reset({ value: this.control.value, disabled: true });
|
|
}
|
|
}
|
|
- instance.control = this.control;
|
|
|
|
- instance.meta = this.meta;
|
|
|
|
|
|
+ instance.control = control;
|
|
|
|
+ instance.meta = meta;
|
|
|
|
|
|
// Add id and classes (as specified)
|
|
// Add id and classes (as specified)
|
|
if (cssId) {
|
|
if (cssId) {
|
|
@@ -90,7 +95,7 @@ export class DynafieldDirective extends NgControl implements OnInit {
|
|
this._control = this.formDirective.addControl(this);
|
|
this._control = this.formDirective.addControl(this);
|
|
}
|
|
}
|
|
} catch (e) {
|
|
} catch (e) {
|
|
- console.error('ERROR INSTANTIATING DYNAFORM FIELD COMPONENT');
|
|
|
|
|
|
+ console.error('ERROR INSTANTIATING DYNAFORM CHILD COMPONENT', type);
|
|
console.log(e);
|
|
console.log(e);
|
|
}
|
|
}
|
|
}
|
|
}
|