feat: add form dialog component (#428)
- Add formfield, input, select base (model) - Add formfield component - Add form-group service - Add form-dialog component Fixes: #427
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
import { Injectable } from '@angular/core';
|
||||
import { FormControl, FormGroup, Validators } from '@angular/forms';
|
||||
|
||||
import { FormfieldBase } from './formfield/model/formfield-base';
|
||||
|
||||
@Injectable({
|
||||
providedIn: 'root'
|
||||
})
|
||||
export class FormGroupService {
|
||||
|
||||
constructor() { }
|
||||
|
||||
createFormGroup(formfields: FormfieldBase[]) {
|
||||
const group: any = {};
|
||||
|
||||
formfields.forEach(formfield => {
|
||||
group[formfield.controlName] = formfield.required ? new FormControl(formfield.value, Validators.required) : new FormControl(formfield.value);
|
||||
});
|
||||
|
||||
return new FormGroup(group);
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user