On Aug 12, 6:46 pm, Matthew wrote:
> Thank you, Rodrigo. Here is a PHP reference for the method you
> suggest,
http://bavotasan.com/tutorials/processing-multiple-forms-on-one-page-...,
> however I'm not sure of the equivalent check for 'array_key_exists' in
> tipfy. Is it an item from kwargs?
Hi,
Here's a quick example with 2 forms in a page. See that both have a
"process" hidden field that identifies what to process. First the
HTML:
<form method="post" action="/">
<input type="hidden" name="process" value="save_user">
<input type="text" name="username">
<input type="submit" name="submit" value="save">
</form>
<form method="post" action="/">
<input type="hidden" name="process" value="save_issue">
<input type="text" name="description">
<input type="submit" name="submit" value="save">
</form>
Then, in the handler:
class MyForm(RequestHandler):
def get(self, **kwarg):
# ... display the forms.
def post(self, **kwargs):
# What to process?
process = self.request.form.get('process')
if process == 'save_user':
# Process user form.
username = self.request.form.get('username')
# ...
elif process == 'save_issue':
# Process issue form.
description = self.request.form.get('description')
# ...
easy, isn't it?
-- rodrigo