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.

Form submit prevention changes #3370

Closed
Closed

Description

@agentcooper

Right now the condition is

if (!attr.action) {
  // prevent submit
}

(https://github.com/angular/angular.js/blob/master/src/ng/directive/form.js#L310)

This breaks lots of existing forms with action="", which is useful when sending POST to the same page. In current situation, to fix this, we need to change our templates to something like action="<? $_SERVER['PHP_SELF'] ?>".

I suggest changing the condition to

if (!attr.action && attr.action !== '') {
  // prevent submit
}

Does this make any sense?

Activity

  1. IgorMinar commented on Aug 28, 2013

    @IgorMinar
    Contributor

    yes. I think this is valid issue. falsy-ness check is not sufficient here as action="" still gets "prevented".

  2. drkwolf commented on Sep 10, 2013

    @drkwolf

    why is it not yet merged ?

  3. thebigredgeek commented on Sep 27, 2013

    @thebigredgeek
    Contributor

    @drkwolf , just build the PR branch locally in the mean time with changes merged in from master

  4. robjames commented on Feb 10, 2014

    @robjames

    +1

  5. totof3110 commented on Sep 13, 2014

    @totof3110

    Just got bitten by this bug. If the action attribute is a substitution based on a variable read asynchronously (Ajax) this seems to also happen:

    <form action="{{someObject.actionUrl}}" method="post">

    => when someObject is the result of an Ajax call, Angular seems to initialize the action tag as an empty string and then prevent default form submit, even after the action is populated.

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