import {Component, OnInit, Input} from '@angular/core';
import {FormGroup, FormBuilder, Validators} from "@angular/forms";


@Component({
    selector: 'entity-form',
    templateUrl: './entity-form.component.html',
})

export class EntityFormComponent implements OnInit{

    @Input('group')
    myForm: FormGroup;

    constructor(private _fb: FormBuilder){}

    ngOnInit(): void {
    }

    public get form() {
        return this._fb.group({
            pid: ['', Validators.required],
            name : ['', Validators.required],
            isEnabled: '',
            _id : ''
        });
    }

    public reset() {
        this.myForm.patchValue({
            pid: '',
            name : '',
            isEnabled: '',
            _id : ''
        });
    }

}
