Components/create-edit-modal: don't add date form control separately

This commit is contained in:
Toast 2025-02-06 17:25:02 +01:00
parent 2de5b804af
commit 58bb2cb3ca

View file

@ -31,18 +31,18 @@ export class CreateEditModalComponent {
private initForm() { private initForm() {
let formattedDate: string let formattedDate: string
this.newShowForm = new FormGroup({
title: new FormControl(this.show?.title, Validators.required),
seasons: new FormControl(this.show?.seasons, [Validators.required, Validators.min(1)]),
episodes: new FormControl(this.show?.episodes, [Validators.required, Validators.min(1)]),
description: new FormControl(this.show?.description, Validators.required)
})
if (this.show?.date !== undefined) { if (this.show?.date !== undefined) {
formattedDate = formatDate(this.show?.date, "YYYY-MM-dd", "en") formattedDate = formatDate(this.show?.date, "YYYY-MM-dd", "en")
} else { } else {
formattedDate = "" formattedDate = ""
} }
this.newShowForm.addControl("date", new FormControl(formattedDate, Validators.required)) this.newShowForm = new FormGroup({
title: new FormControl(this.show?.title, Validators.required),
seasons: new FormControl(this.show?.seasons, [Validators.required, Validators.min(1)]),
date: new FormControl(formattedDate, Validators.required),
episodes: new FormControl(this.show?.episodes, [Validators.required, Validators.min(1)]),
description: new FormControl(this.show?.description, Validators.required)
})
} }
protected dismiss() { protected dismiss() {