0
votes

I am using Pyramid for my backend, and with my frontend I am using Jinja2 templates, with AngularJS.

The forms I use within pyramid all send data to the request, a standard html form would look like:

<form class="form-horizontal" method="post" accept-charset="utf-8" enctype="multipart/form-data">
<input type="submit" class="btn-u" name="form.submitted" value="CreateW"/>

Now I have added angularJS validation, the standard form does not submit data to request.params, or even perform a submit.

I tried using an angular button:

<button type="submit" class="btn-u" name="form.submitted">Create</button>

But that did not work either, how can I modify this angular form to post data to pyramids request.

Thanks

1
i don't know angular, but your form is missing an action attribute. w3schools.com/tags/att_form_action.asp - Tom Willis
The action is just the url which I removed for the sample post - crooksey
what do you mean by angular button? As far as i see/know, there is not angular button at all - Chung

1 Answers

0
votes

Looking at Angular docs it says that by default the data object is serialized to JSON when sent to the server, so you can catch it via request.json_body in Pyramid. Or you can override the default Angular transformation with $httpProvider.defaults.transformRequest.

http://docs.angularjs.org/api/ng.$http

http://docs.pylonsproject.org/projects/pyramid/en/1.5-branch/narr/webob.html#request-json-body