diff --git a/src/components/form/Form.js b/src/components/form/Form.js index 6bd19a666a..c682fcf69e 100644 --- a/src/components/form/Form.js +++ b/src/components/form/Form.js @@ -161,7 +161,10 @@ export default class FormComponent extends Component { // Make sure to not show the submit button in wizards in the nested forms. _.set(options, 'buttonSettings.showSubmit', false); - + + // Set the parent option to the subform so those references are stable when the subform is created + options.parent = this; + if (!this.options) { return options; } @@ -440,12 +443,11 @@ export default class FormComponent extends Component { return (new Form(form, this.getSubOptions())).ready.then((instance) => { this.subForm = instance; this.subForm.currentForm = this; + this.subForm.parentVisible = this.visible; const componentsMap = this.componentsMap; const formComponentsMap = this.subForm.componentsMap; _.assign(componentsMap, formComponentsMap); - this.component.components = this.subForm.components.map((comp) => comp.component); - this.subForm.parent = this; - this.subForm.parentVisible = this.visible; + this.component.components = this.subForm.components.map((comp) => comp.component); this.subForm.on('change', () => { if (this.subForm) { this.dataValue = this.subForm.getValue();