Let's say you have a form with several posts:
<form method="POST" action="/etc"> <input name="foo" type="submit" value="Foo!"> <input name="bar" type="submit" value="Bar!"> </form>
Checking which submit button is pressed in PHP is simple:
if (isset($_POST['foo'])) { return 'foo' } if (isset($_POST['bar'])) { return 'bar' }
What is the Python.Bottle equivalent?
I tried:
if (request.POST.get('foo')): return 'foo' if (request.POST.get('bar')): return 'bar'
But this returns a KeyError, which means that "foo" and "bar" are not in the "POST dict" field.
I also tried adding a test field to the form and returning the value in this field when the form is submitted and works fine, so the form is submitted.
One thing that may be important: submit buttons on the form are dynamically generated.
EDIT: A possible problem was found. I use jQuery to publish and serialize form data, but obviously jQuery serializes the omits submit buttons from the output, which will definitely lead to what I see. Currently working on a workaround, but any help is still appreciated.
source share