-
Notifications
You must be signed in to change notification settings - Fork 27.5k
ng-submit doesn't work with ng-form #2513
Comments
As part of our effort to clean out old issues, this issue is being automatically closed since it has been inactivite for over two months. Please try the newest versions of Angular ( Thanks! |
Yep, this issue is still around (as of 1.2-rc.2). I'll test on rc3 and update this ticket. EDIT: Confirmed, this is still broken in rc3. Relevant Plnkr UPDATE: I tried my hand at a fix (adding 'submit' trigger to ngForm's input elements (onclick)), but I know I'm going about it the wrong way. Here's what I have so far. |
fire 'submit' event when submit buttons are clicked in an ngForm (since ngForms don't automatically fire the 'submit' event) Closes angular#2513
+1 I'm seeing this in 1.2.0. |
Confirmed, this is happening in 1.2.2. |
From the looks of it, it cannot work as Pressing enter in a text field -> submit |
I can confirm this issue for 1.2.9, using ng-form instead of form as an element means that ng-submit will not work |
I can also confirm this issue exists in 1.2.13. |
+1 |
+1 |
Could you listen to |
I imagine we’ll also need to watch for when the form’s submit button is actioned (either by mouse or keyboard… or touch, ha). |
+1. The docs say that NG-FORM is a replacement for FORM but it isn't if submit doesn't work. If this can't be done then it should at least be noted in the docs. |
I agree that this should be a built-in functionality of |
+1 |
+1, however, are there any decisions about how event handling with |
I've had a little play trying to get the I'm not sure how to polyfill this behaviour exactly. What buttons should trigger the submit event? All of them, or only the first? I believe I've also created a fiddle to demonstrate the default behaviour of a |
Hi, |
Perhaps ng-fieldset would be a more appropriate name then. |
A case where it would be nice to have <!-- used to group and check the validity of all the forms with global.$valid -->
<form name="global">
<!-- the actual, usable forms -->
<ng-form name="form" ng-repeat="..." ng-submit="handle()">
<!-- used for controls grouping -->
<ng-form name="group" ng-repeat="..."></ng-form>
<button type="submit">Submit</button>
</ng-form>
</form> (see Plunker) ... and want to be able to check the validity of all the forms. |
Why would want to check the validity of all forms, if you can submit them separately ? |
In this specific case, the user can save each model separately, or save all the models. Therefore, I need to know if each model's form is valid to wether enable the "Save All" button or not. I edited the previous post with this Plunker (see the comment in the HTML). |
A client has a wizard like form with several input fields plus some nested forms for grouping (steps). We need to validate each step with a "submit"-like trigger and maybe also firing some backend calls. We tried using plain
I think it is a valid use case to handle a submit of nested forms, also firing backend calls or whatever, so this should be at least a feature request. |
I have the following use case: A user can edit a list (edit entries, add new entries, delete entries) and then either cancel his changes (which resets the list to what it was before) or save all changes. The whole cancel or save action happens within a form, so all fields are being checked and validated on submit. But when the user tries to add a new entry, this entry should also be checked and validated before being added to the list. Of course the complete list is being validated in the most outer form, but it would be nice to validate this 'new entry' sub-form - primary because of disabling some buttons and using the automatic 'submit via enter' functionality, so basically because of UI and UX awesomeness ;) So in my optinion this feature would really be nice to have. |
+1 |
3 similar comments
+1 |
+1 |
+1 |
Also having this issue. EDIT: I ended up working out my particular use case by giving individual forms interpolated names (as indicated in this stackoverflow answer) and validating each one individually. For instance (using
I didn't bother to give each form control interpolated names though, since they are objects within the form. |
ng-submit still doesn't work with ng-form (so ng-form is not just alias of form). |
Here's an update for everyone, since I ran into this issue myself. Here's the directive code on github (no jQuery depedencies or anything) Directive fix (no jQuery or any other dependencies):With this directive, any ngForm directive useage: (Automatically calls any input/button with type="submit")
ngSubmit functionality fix for ngForm:
This would be nice to have built-in to Angular, since like most of you are saying, ngForm without ngSubmit or even the Enter key working (and hitting a submit) is kind of pointless. I'm going to see if I can potentially make a Pull-Request for this issue. |
@mcpDESIGNS you can make pull request and team will consider if they can make it built-in. But before it, please consider to add tests and please don't use "ng" prefix for custom directives, it's kind of "reserved" :) |
@e-oz I'll take a look, doesn't seem like it'd be too bad to tackle natively. Oh of course! I never use |
The demo link is not working so I made a new one on bin |
@moshfeu Sorry about that, just fixed the link to it, the Demo should work now! |
A. The problem is if there are multiple buttons, the first will be the Another problem that there is no This is very strange based on the fact that the I tried:
Any suggestions? Thanks |
Very nice, you're totally right I'll have to look into the other issue, you might just need to set some other type of variable to temporarily let everything know it was "submitted". It might have something to do with the fact that there's a |
Finally I got this! I added I sent a Pull Request. Tell me if it's OK. Thanks! |
We are all set :) @moshfeu Thanks for the PR. |
Thank you. The PR works for me. |
Here's a plunkr to ilustrate the behaviour....
http://plnkr.co/edit/gist:3510140?p=preview
The text was updated successfully, but these errors were encountered: