Skip to content
This repository has been archived by the owner on Apr 12, 2024. It is now read-only.

Do not preventDefault on form submit if action="" #5962

Closed
tomzx opened this issue Jan 23, 2014 · 3 comments
Closed

Do not preventDefault on form submit if action="" #5962

tomzx opened this issue Jan 23, 2014 · 3 comments

Comments

@tomzx
Copy link

tomzx commented Jan 23, 2014

Hi,

The current code/documentation (http://docs.angularjs.org/api/ng.directive:form) says the following about a form default action:

Submitting a form and preventing the default action
[...]
For this reason, Angular prevents the default action (form submission to the server) unless the <form> element has an action attribute specified.

Yet, if you specify <form action="">...</form>, angularjs consider that no action attribute is specified, which is not true.

The test condition in src/ng/directive/form.js is not strict enough (in the form directive)

if (!attr.action) {

I'm no JS expert, but I think a stricter comparison would be more appropriate (such as the following)

if (typeof attr.action === 'undefined') {
@xel1045
Copy link

xel1045 commented Jan 23, 2014

@mhov
Copy link

mhov commented Mar 7, 2014

A lot of us are mixing Angular into our traditional site frameworks rather than full SPAs, so the fact that all form tags get auto-directive'd causes a lot of unexpected issues like these.

An even better fix (I think) would be removing ngForm's form alias (or allowing us to via module configuration) and making all forms opt-in via ng-form='' attributes, although I imagine it's too much of a breaking-change for a minor update.

Maybe a <form ng-form-ignore='' >... that prevents the controller from binding/initializing at all?

ngForm still has some growing up to do (ex. validation on dynamically named inputs) and it's a real bummer when it interferes with our non-angular functionality.

@Narretz Narretz added this to the Backlog milestone Jun 25, 2014
@Narretz
Copy link
Contributor

Narretz commented Jun 25, 2014

This is a duplicate of #3370, with a pr in #3776

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

4 participants