Discussion:
[bottlepy] Form with dynamic rows (equal field names)
Stefan Walkner
2015-05-04 12:13:36 UTC
Permalink
Hello,

I have been searching around the forum, bottle documentation, etc but I
couldn't find a hint for the problem I have:
I have a form which is represented in a html table as a row (tr).
I have some jquery functionality to add and delete rows.
When I submit the form (all rows) I use
'request.POST.getlist("field-name")' to retrieve every rows value.
The problem is: I'd like to be able to do validation on the form and just
display the same form again. This functionality is also needed, when
editing an already persisted set of values.

Can someone please give me a hint how I can achieve that?

Thank you in advance
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Stefan Walkner
2015-05-05 07:05:20 UTC
Permalink
Hello again,

I played around a little. I know - there is wtforms, but since I have
'equal' field names across several lines I wasn't able how to handle it.
So I created my form with HTML (and a few functions to draw selects, etc).

Then there are two functions:
@app.post('/edit/<name>')
@view("myform")
def edit(name):

@app.post('/create')
@view("myform")
def create():

both get the data from the HTML form and call a single 'persistence'
method. One time with 'update' and one time with create.
I pre-fill the form values by reading the data (not DB but json file) and
manually creating a FormsDict() structure which then does all the
pre-filling as if it was prefilling due to validation error.

If anyone has a better suggestion (I think there really is..) - I would be
thankfully looking for :-)

stefan
Post by Stefan Walkner
Hello,
I have been searching around the forum, bottle documentation, etc but I
I have a form which is represented in a html table as a row (tr).
I have some jquery functionality to add and delete rows.
When I submit the form (all rows) I use
'request.POST.getlist("field-name")' to retrieve every rows value.
The problem is: I'd like to be able to do validation on the form and just
display the same form again. This functionality is also needed, when
editing an already persisted set of values.
Can someone please give me a hint how I can achieve that?
Thank you in advance
--
--
You are member of the "bottlepy" group at google groups.
See http://groups.google.de/group/bottlepy for mailing list options.
See http://bottlepy.org/ for news and documentation.

---
You received this message because you are subscribed to the Google Groups "bottlepy" group.
To unsubscribe from this group and stop receiving emails from it, send an email to bottlepy+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...