Skip to content

Expose an API to reset the submitted state of a form #60274

@javierFerFer

Description

@javierFerFer

Which @angular/* package(s) are relevant/related to the feature request?

No response

Description

Hi guys! I want to propose something:
The last days I was working with reactive forms in our app and I saw that exist 2 ways to reset a form object (reactive one), one is using the method called .reset() inside of formGroup variable, in this method you can pass a value as input + if you want to emit changes + onlyself.

The other way is to use formGroupDirective + with the method called resetForm(), I was checking the code inside of the repo and I saw that this method, apart from doing another stuffs, just use .reset() internally.

The problem with that is .resetForm() is the only way to reset submitted status of the form, but this is gonna trigger any observable that is listening about form changes.

The only work around that I saw to solve this is using a filtering inside of my observable to not trigger it when the state of the form is submitted, but I think that could exist a better way to do it.

Proposed solution

My proposal have 2 possibles ways:

  1. add the possiblity to set a second optional parameter to resetForm method as the same way as .reset() method inside of form variable.
  2. expose a new api to just reset the submitted state of the form as well as you can reset the value of the form and states too.

Alternatives considered

If exist a way to do what Im explaining here, please let me know it because I didn't see any info related to do that inside of angular documentation (angular.dev)

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions