Reactive form valid property return false when form is disabled

Discussão em 'Angular' iniciado por Muhammed Albarmavi, Fevereiro 10, 2025.

  1. I have this simple form and used in create and update cases so for create case the user will enter the data and base on validatorsI will get the form.valid (true,false). In update case I just get the data from api and set this value to the form and make the form disable;

    this.form = fb.group({
    name: ['', Validators.required],
    lastName: ['', Validators.required],
    address: [''],
    });


    so when I make the form disabled the valid value always is false;

    ngOnInit() {
    this.form.patchValue({
    name: 'name',
    lastName: 'Last Name'
    });

    this.form.disable();
    }


    stackblitz example

    Continue reading...

Compartilhe esta Página