Holiday Notice: Support will be provided on a limited scale from December 24th, 2024, to January 2nd, 2025. Happy holidays and a wonderful New Year!


Topic: Issue disabling inputs using FormControl and mdb-form-control

Dave Moniz priority asked 3 years ago


Expected behavior

Setting a FormControl to be disabled using the recommended method should work

Actual behavior

It doesn't. Additionally, doing it the way recommended in the MDB documentation ( [disabled]="true" ) throws a angular warning

Resources (screenshots, code snippets etc.)

HTML

<mdb-form-control>
    <input mdbInput [mdbValidate]="true" id="firstname" name="firstname" formControlName="firstnameControl" type="text" class="form-control">
    <label mdbLabel for="firstname" class="form-label">First name</label>
    <mdb-error *ngIf="(firstnameControl?.invalid && (firstnameControl?.dirty || firstnameControl?.touched))">This must not be blank</mdb-error>
    <mdb-success *ngIf="firstnameControl?.valid && (firstnameControl?.dirty || firstnameControl?.touched)"></mdb-success>
</mdb-form-control>

TS

this.formGroup = new FormGroup({
    firstnameControl: new FormControl({
        value: this.firstname, disabled: true }, {
        validators: [Validators.required], updateOn: 'change'
    })
});

using the code (above) does not result in a disabled field, additionally this does not disable the field: this.firstnameControl.disable();


Arkadiusz Idzikowski staff commented 3 years ago

@Dave Moniz We will take a closer look at this and add possibility to disable the control using Angular form control. For now, please use [disabled] on mdbInput, Angular will always suggest to handle disabled state using FormControl options, but this warning should not be displayed in production build.


Dave Moniz priority answered 3 years ago


Can confirm this is addressed as of v1.1.0, closing now.


FREE CONSULTATION

Hire our experts to build a dedicated project. We'll analyze your business requirements, for free.

Status

Closed

Specification of the issue

  • ForumUser: Priority
  • Premium support: Yes
  • Technology: MDB Angular
  • MDB Version: MDB5 1.0.0-beta5
  • Device: PC
  • Browser: Google Chrome
  • OS: Arch Linux
  • Provided sample code: Yes
  • Provided link: No