Skip to content

AbstractControl.markAs* asymmetry is confusing, limiting #11774

@xealot

Description

@xealot

I'm submitting a ... (check one with "x")

[x] bug report
[x] feature request

Current behavior
There are markAs methods that can manipulate a form's internal validation state. These are highly useful. However, they propagate to children only sometimes.

The following methods also mark their children:
markAsUnTouched
markAsPristine

These methods do not mark their children:
markAsTouched
markAsDirty

I'm not even sure what this method is for...
markAsPending

Expected behavior
All methods to mark validation should interact with their groups either always or optionally.

Alternatively, some basic iteration machinery should be introduced so that we may instrument our own state changes easily.

What is the motivation / use case for changing the behavior?
For example; I want to show validation when loading a record from the DB but I would prefer not to show validation when creating a new record. It would be convenient to to mark everything as dirty or at least touched (as my validation would key off of those states) at the form level.

Conceptually, considering the semantic meaning of FormGroup, it seems if a parent control is marked as dirty that would indicate the children are dirty as well. The same reasoning which was originally used to implement reset() and the other markAs functions that handle their children.

  • Angular version: 2.0.0
  • Browser: all
  • Language: all

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions