updated author's forms

This commit is contained in:
2025-11-11 14:08:59 +01:00
parent 9ef353924f
commit ce21596610
23 changed files with 271 additions and 13 deletions

View File

@@ -0,0 +1,38 @@
import {Component, input} from '@angular/core';
import {FormControl, FormGroup, FormsModule, ReactiveFormsModule, Validators} from "@angular/forms";
import {NzColDirective, NzRowDirective} from "ng-zorro-antd/grid";
import {NzFormControlComponent, NzFormDirective, NzFormItemComponent, NzFormLabelComponent} from "ng-zorro-antd/form";
import {AuthorInfo} from "../../interfaces/author.interfaces";
@Component({
selector: 'app-create-author',
imports: [
FormsModule,
NzColDirective,
NzFormControlComponent,
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzRowDirective,
ReactiveFormsModule
],
templateUrl: './create-author.html',
styleUrl: './create-author.css',
})
export class CreateAuthor {
createAuthorForm = new FormGroup({
name: new FormControl<string>(null, [Validators.required]),
firstName: new FormControl<string>(null, [Validators.required])
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.createAuthorForm.invalid) return;
// Pour obtenir la valeur du formulaire
console.log(this.createAuthorForm.getRawValue())
// Pour vider le formulaire
this.createAuthorForm.reset()
}
}