Hi
I have jquery driven dynamic form with many fields, Is it possible to
POST them to web2py controller.
This is pseudo-code. I want to know is it doable. Can I make simple
form in web2py and POST some raw data fields and get them in
controller side and manually insert them to the database.
In my case the form is not fixed so I cannot build in on controller
side, probably i have to make something like a fake table but how many
virtual fields.
I searched a lot in this forum and cudnt find any solution, maybe i
dont know the correct searching key words.
I am sure I am not the first one who is asking about this Raw form
POST.

MODEL:
db.define_table('person',
        Field('user_id', db.auth_user, default='0'),
        Field('name', length=128, default=''),
        Field('address', length=256, default=''),
        Field('postcode', length=128, default=''),
        Field('city', length=128, default=''),
))

For example I want to import 4 people living in same city. Just
name,address and PostCode fields are different.

VIEW:
<form action="/add_people" method="POST">
<input name="city" type="text" />
<div>
<input type="text" name="name[0]" />
<input type="text" name="address[0]" />
<input type="text" name="postcode[0]" />
</div>
<div>
<input type="text" name="name[1]" />
<input type="text" name="address[1]" />
<input type="text" name="postcode[1]" />
</div>
...
....
...
<input type="submit" value="Submit" />
</form>

How can I handle this on server side
CONTROLLER:
get POST vars list and manually insert them

def add_people:
     request.vars
     .....
     for p in people:
           db.executesql("INSERT INTO person values (name, address,
postcode, city)");





Plz give me some advices.

Thanks.

Reply via email to