Skip to content
This repository has been archived by the owner on Feb 28, 2023. It is now read-only.

MODUL-1153 - M-Form not reactive when dynamically adding controls to form groups #1094

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 3 additions & 9 deletions src/utils/form/form-group.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import Vue from 'vue';
import { AbstractControl } from './abstract-control';
import { ControlError } from './control-error';
import { ControlOptions } from './control-options';
Expand Down Expand Up @@ -135,24 +136,17 @@ export class FormGroup<T = any> extends AbstractControl {
throw Error(`There is already a control with name ${name} in this group`);
}

const result: any = Object.assign(this._controls);

control.parent = this;
result[name] = control;

this._controls = result;
Vue.prototype.$set(this._controls, name, control);
}

public removeControl(name: string): void {
if (this._controls[name] === undefined) {
throw Error(`There is no control with name ${name} in this group`);
}

const result: any = Object.assign(this._controls);

delete result[name];

this._controls = result;
Vue.prototype.$delete(this._controls, name);
}

private setupControlsParent(): void {
Expand Down