Components/create-edit-modal: move FormGroup init to separate function

This commit is contained in:
Toast 2025-02-05 01:51:15 +01:00
parent be31699167
commit fd41663f86

View file

@ -4,6 +4,7 @@ import {FormControl, FormGroup, ReactiveFormsModule, Validators} from '@angular/
import {ShowsApiService} from '../../../services/shows/shows-api.service';
import {ShowsApiCreation} from '../../../interfaces/shows-api-creation';
import {ToastService} from '../../../services/toast/toast.service';
import {Show} from '../../../interfaces/show';
@Component({
selector: 'app-create-edit-modal',
@ -17,12 +18,16 @@ export class CreateEditModalComponent {
private activeModal = inject(NgbActiveModal)
private showsService = inject(ShowsApiService)
private toastService = inject(ToastService)
protected newShowForm: FormGroup
protected newShowForm: FormGroup = new FormGroup({})
protected editMode: boolean = false
protected show?: Show
constructor() {
this.initForm()
}
private initForm() {
this.newShowForm = new FormGroup({
title: new FormControl(this.show?.title, Validators.required),
date: new FormControl(this.show?.date, Validators.required),