AngularJs Blocks Form Submit without "action"

AngularJs is very useful framework and we often use it in our pages,but there are some situations,when we see that our form submit does not work.Why did this happen?Here is the answer of that.AngularJs blocks form submissions,if forms' action is empty.

Since AngularJS is now a deprecated framework, you can use JavaScript modern frameworks like Vuejs, React and Angular, instead.

In general we meet this problem, if we use symfony+angularjs,because symfony lets us to generate form and if we don't set the action url,then it will be empty.That's why sometimes angular does not let to submit the form.It's invalid.

But what is the solution?I don't want to set any url on form action,because I don't need it.

The solution is: Set action "#" symbol like this ... action="#" ...

If you use Symfony Forms, then you have to do like this:

$form = $this->createFormBuilder($data,
           array("action" => $this->generateUrl("route_to_curent_path"))))
           ->add('field', 'text')
           ->add('submitButton', 'submit')

Do you find this helpful?

Related articles