Which @angular/* package(s) are relevant/related to the feature request?
No response
Description
I'm submitting a...
[ ] Regression (a behavior that used to work and stopped working in a new release)
[ ] Bug report
[x] Feature request
[ ] Documentation issue or request
[ ] Support request => Please do not submit support request here, instead see https://github.com/angular/angular/blob/master/CONTRIBUTING.md#question
Current behavior
In standard HTML/TypeScript, without angular, it's possible to get a HTMLFormElement and call either .sumbit() or .reset() on it to submit it programmatically. If we want to do this in an Angular2 Component, we will need to either:
- have a
@ViewChild('myForm') formElementRef, casting the formElementRef.nativeElement to HtmlFormElement and then call .submit() on it
- have a hidden
input type="sumbit" (or similar), again do a @ViewChild on it and trigger it programmatically.
Note that in the case of .reset() this is very well supported and documented.
What is the motivation / use case for changing the behavior?
Some UIs will require us to have the submit element outside of the <form>, or to submit a form relying on different mechanism/conditions (e.g., time triggered for a game-like UI).
Proposed solution
To be able to trigger the .submit() operation directly from SignalForm would be really helpful.
There are cases where, for practical UI/UX reasons the submit button cannot be in the <form> element itself. Although this is far from ideal, it's still something that can be and is done.
Minimal reproduction of the problem with instructions
<button #submit>Submit!<button><form [formGroup]="form" (submit)="submitted()">[...]</form>
Then try to submit the form without using an ElementRef or a hidden submit inside the <form>.
Alternatives considered
This was originally #20562 on ReactiveForms, which has been closed because we are moving on from ReactiveForm.
The feature then had over 40 upvotes and was deemed as "the demand is real" (#20562 (comment), by @arturovt).
The advice was to resubmit the feature request against SignalForms. This is that.
Which @angular/* package(s) are relevant/related to the feature request?
No response
Description
I'm submitting a...
Current behavior
In standard HTML/TypeScript, without angular, it's possible to get a HTMLFormElement and call either
.sumbit()or.reset()on it to submit it programmatically. If we want to do this in an Angular2 Component, we will need to either:@ViewChild('myForm') formElementRef, casting theformElementRef.nativeElementtoHtmlFormElementand then call.submit()on itinput type="sumbit"(or similar), again do a@ViewChildon it and trigger it programmatically.Note that in the case of
.reset()this is very well supported and documented.What is the motivation / use case for changing the behavior?
Some UIs will require us to have the submit element outside of the
<form>, or to submit a form relying on different mechanism/conditions (e.g., time triggered for a game-like UI).Proposed solution
To be able to trigger the
.submit()operation directly from SignalForm would be really helpful.There are cases where, for practical UI/UX reasons the submit button cannot be in the
<form>element itself. Although this is far from ideal, it's still something that can be and is done.Minimal reproduction of the problem with instructions
<button #submit>Submit!<button><form [formGroup]="form" (submit)="submitted()">[...]</form>Then try to submit the form without using an
ElementRefor a hidden submit inside the<form>.Alternatives considered
This was originally #20562 on ReactiveForms, which has been closed because we are moving on from ReactiveForm.
The feature then had over 40 upvotes and was deemed as "the demand is real" (#20562 (comment), by @arturovt).
The advice was to resubmit the feature request against SignalForms. This is that.