question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

RC6 Forms: when value is null, control is not disabled

See original GitHub issue

I’m submitting a bug (check one with “x”)

[x] bug report => search github for a similar issue or PR before submitting
[ ] feature request
[ ] support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question

Current behavior

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

the control first will not be disabled

Expected/desired behavior first shall be disabled because disabled is true, even so the input is null. If the value is empty (‘’), it will not be disabled either. In other words, the input seems disabled only, and only if the input has a value defined

Reproduction of the problem

What is the expected behavior?

What is the motivation / use case for changing the behavior?

Please tell us about your environment:

  • Angular version: 2.0.0-rc.6
  • Browser: [ Chrome 52 ]
  • Language: [ TypeScript ]

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
karacommented, Sep 1, 2016

@Krisa We were running the disabled check too late. Should be fixed by #11257.

1reaction
karacommented, Sep 1, 2016

Oh hey. That’s pretty weird. So if you put value as null and the control is disabled and you have the required validator, something is going wrong. I’ll look into it!

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to disable form control but keep value - Stack Overflow
Assuming you have a disabled property in your component. You have to retun null not false to enable the input. Share.
Read more >
Angular2 RC6 disabled input – iTecNote
After upgrading to Angular2 RC6 I'm getting the following message in the ... form = new FormGroup({ first: new FormControl({value: 'Nancy', disabled: true}, ......
Read more >
Exploring the difference between disabling a form control ...
Our form's value will not sync with our application state store because when the observer executes, it will find that the form's status...
Read more >
ng-dynamic-forms documentation
6, Angular does not allow property bindings of the disabled attribute in reactive forms. Yet updating either the value or status of a...
Read more >
Disabling Form Controls When Working With Reactive Forms ...
You can enable/disable a form control by using the following ways: Instantiate a new FormControl with the disabled property set to true. FormControl({value:...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found