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

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

Closed

Description

@tomzx

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') {

Activity

  1. xel1045 commented on Jan 23, 2014

    @xel1045
  2. mhov commented on Mar 7, 2014

    @mhov

    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.

  3. added this to the milestone on Jun 25, 2014
  4. Narretz commented on Jun 25, 2014

    @Narretz
    Contributor

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions