providers create form added

This commit is contained in:
2025-11-27 16:42:53 +01:00
parent 6235df5482
commit 20ddd65dc3
21 changed files with 422 additions and 0 deletions

View File

@@ -0,0 +1,42 @@
import { Component } 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 {NzInputDirective} from "ng-zorro-antd/input";
@Component({
selector: 'app-customers-add-form',
imports: [
FormsModule,
NzColDirective,
NzFormControlComponent,
NzFormDirective,
NzFormItemComponent,
NzFormLabelComponent,
NzInputDirective,
NzRowDirective,
ReactiveFormsModule
],
templateUrl: './customers-add-form.html',
styleUrl: './customers-add-form.css',
})
export class CustomersAddForm {
customerForm = new FormGroup({
lastName: new FormControl<string>(null, [Validators.required]),
firstName: new FormControl<string>(null, [Validators.required]),
phoneNumber: new FormControl<string>(null, [Validators.required]),
email: new FormControl<string>(null, [Validators.required]),
address: new FormControl<string>(null, [Validators.required]),
role: new FormControl<string>(null, [Validators.required]),
})
submitForm() {
// Pour annuler si le formulaire est invalide
if (this.customerForm.invalid) return;
// Pour obtenir la valeur du formulaire
console.log(this.customerForm.getRawValue())
// Pour vider le formulaire
this.customerForm.reset()
}
}