Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Md-Input Bug - When using reactive forms, setting control to disabled does not work #1880

Closed
qdouble opened this issue Nov 15, 2016 · 2 comments

Comments

@qdouble
Copy link

qdouble commented Nov 15, 2016

Bug, feature request, or proposal:

[x] Bug

What is the expected behavior?

You should be able to set the form control to disabled without setting the attribute in the HTML code (as angular complains if you set the disabled attribute when using reactive forms)

What is the current behavior?

It just silently fails to disable the control.

What are the steps to reproduce?

Just set the control to disabled when creating it or at any other time.
Reproduction here: http://plnkr.co/edit/RQBaGGe1p1jIBMv79Kgo?p=preview

What is the use-case or motivation for changing an existing behavior?

If you try to set disabled property using the attribute instead, angular will give a warning/error:

reactive_errors.js:30 
      It looks like you're using the disabled attribute with a reactive form directive. If you set disabled to true
      when you set up this control in your component class, the disabled attribute will actually be set in the DOM for
      you. We recommend using this approach to avoid 'changed after checked' errors.
       
      Example: 
      form = new FormGroup({
        first: new FormControl({value: 'Nancy', disabled: true}, Validators.required),
        last: new FormControl('Drew', Validators.required)
      });

Which versions of Angular, Material, OS, browsers are affected?

Angular - 2.2.0
Material - Alpha-10

@kara
Copy link
Contributor

kara commented Nov 17, 2016

This looks like a duplicate of #1171. Should be fixed by PR #1750

@kara kara closed this as completed Nov 17, 2016
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants