Disable Input fields in reactive form

reactive form disable input
disable form control angular 4
angular 7 disable input
angular 6 disable input on condition
angular reactive forms disable input
disable form control angular 8
angular 4 disable input on condition
angular disable form

I already tried to follow the example of other answers from here and I did not succeed!

I created a reactive form (ie, dynamic) and I want to disable some fields at any given time. My form code:

this.form = this._fb.group({
  name: ['', Validators.required],
  options: this._fb.array([])

const control = <FormArray>this.form.controls['options'];
  value: ['']

my html:

<div class='row' formArrayName="options">
  <div *ngFor="let opt of form.controls.options.controls; let i=index">
    <div [formGroupName]="i">
      <select formArrayName="value">
        <option>{{ opt.controls.value }}</option>

I reduced the code to facilitate. I want to disable the field of type select. I tried to do the following:

form = new FormGroup({
  first: new FormControl({value: '', disabled: true}, Validators.required),

not working! Does anyone have a suggestion?

name: [{value: '', disabled: true}, Validators.required],
name: [{value: '', disabled: this.isDisabled}, Validators.required],



Disable Input fields in reactive form, name: [{value: '', disabled: true}, Validators.required], name: [{value: '', disabled: this.isDisabled}, Validators.required],. or How to disable an Angular ReactiveForm Input based on another input. Step 1: Assuming you have a component shell ready, import the following libraries: import { Component, OnInit, Input, EventEmitter } from Step 2: Declare and initialise the following class variables. What you initialise

Pay attention

If you are creating a form using a variable for condition and trying to change it later it will not work, i.e. the form will not change.

For example

this.isDisabled = true;

this.cardForm = this.fb.group({
    'number': [{value: null, disabled: this.isDisabled},

and if you change the variable

this.isDisabled = false;

the form will not change. You should use



You should use patchValue method for changing value:

    'number': '1703'

Angular, This blog post makes use of reactive forms, but the examples should be that there isn't something like a disabled attribute on a form tag as there is on an input​. When working with Angular Reactive Forms there are times when you need to disable/enable a form control, for example: <input [formControl]="formControl" [disable]="condition"> If you’ve ever tried the above code, you probably have encountered the following warning. It looks like you’re using the disabled attribute with a reactive form directive.

It is bad practice to use disable in a DOM with reactive forms. You can set this option in your FormControl, when you init the from

username: new FormControl(
    value: this.modelUser.Email,
    disabled: true

Property value is not necessary

Or you can get your form control with get('control_name')and set disable


How To Disable Angular ReactiveForm Input Based On Selection , This is particularly useful if you are using Angular's Reactive Forms to any other country, the State input field will automatically be disabled. Is there any way to disable the entire form in angular when using Reactive forms. I know it is possible to make them disable one by one. this.tempForm = this.fb.group({ m26_type: '', m26_nam

A more general approach would be.

// Variable/Flag declare
public formDisabled = false;

// Form init
this.form = new FormGroup({
  name: new FormControl({value: '', disabled: this.formDisabled}, 

// Enable/disable form control
public toggleFormState() {
    this.formDisabled = !this.formDisabled;
    const state = this.formDisabled ? 'disable' : 'enable';

    Object.keys(this.form.controls).forEach((controlName) => {
        this.form.controls[controlName][state](); // disables/enables each form control based on 'this.formDisabled'

Disable Input fields in reactive form - angular - html, I want to disable the field of type select. I tried to do the following: form = new FormGroup({ first: new FormControl({value: '', disabled: true}, Validators.required)​,  formCtrl.disable() is not working, as it sets disabled to Covalent file input control only. As a file input control renders a wrapper with a button inside, a button never gets disabled. And btw, I am not mixing form approach, I am using reactive form only.

If to use disabled form input elements (like suggested in correct answer how to disable input) validation for them will be also disabled, take attention for that!

(And if you are using on submit button like [disabled]="!form.valid"it will exclude your field from validation)

How to set file input disabled in reactive form in typescript? · Issue , Looks like you are mixing reactive and template driven forms. In your component class you'll want to use the formCtrl.disable() method on the  Angular2 Reactive Forms - Disable form control dynamically from condition. Disable Input fields in reactive form. 2. Programmatically disable a reactive form

Reactive forms, bug report Description Hi guys Im busy working with reactive forms and I need to the ability to have disabled forms, that completely disable  How to disable a text area or mat-form-field. + Angular Material and Reactive Forms for my Form Field. How can I disable that? Creating the form group input

angular-reactive-forms-disable-shit, const form = new FormGroup({. // sometime happens that some shittyInput: new FormControl("text", angular-reactive-forms-disable-shit. Editor. Preview. Both. I think I figured out the problem, this input field is part of a reactive form (?), since you have included formControlName. This means that what you are trying to do by disabling the input field with is_edit is not working, e.g your attempt [disabled]="is_edit", which would in other cases work.

Reactive forms, Reactive forms provide a model-driven approach to handling form inputs has a disabled binding attached to it to disable the button when profileForm is invalid. Reactive-forms in Angular is very powerful to handle changes in value, check the statuses, and perform validations on a form-field in particular form because of supporting FormGroup, FormControl

  • How could the select be disabled, when you are trying to disable some formcontrol called first?`:)
  • It was just typo. I want to disable select. Can you help me?
  • Could you reproduce a plunker?
  • Are you trying to disable the whole select? And value is not a formArray, it's a formControlName. If you want value to be a formArray you would have to change it. Currently it's a formControlName. So if you want the whole select field to be disabled, just change <select formArrayName="value"> to <select formControlName="value">