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

Form submit prevention changes #3370

Closed
agentcooper opened this issue Jul 27, 2013 · 5 comments
Closed

Form submit prevention changes #3370

agentcooper opened this issue Jul 27, 2013 · 5 comments

Comments

@agentcooper
Copy link
Contributor

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?

@IgorMinar
Copy link
Contributor

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

@drkwolf
Copy link

drkwolf commented Sep 10, 2013

why is it not yet merged ?

@thebigredgeek
Copy link
Contributor

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

@robjames
Copy link

+1

@totof3110
Copy link

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 subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants