There is no form.vars.company -- it's form.vars.company_0, form.vars.company_1, etc. So:
db.company.insert(company=form.vars['company_%s' % i]) Anthony On Saturday, March 16, 2013 9:27:11 AM UTC-4, 黄祥 wrote: > > yeah my mistake i didn't notice, thanks for correcting me, anthony. i've > already test the form is work fine, but it can't insert it into database. > i've tried to add some code for that but the result is not expected (no > error occured), here is the database table content, after i input and > submit it. the others strange is when i refresh the page, the table is fill > it up with the data (not input by me). > > company.id<http://127.0.0.1:8000/test/appadmin/select/db?orderby=company.id> > company.company<http://127.0.0.1:8000/test/appadmin/select/db?orderby=company.company> > 1 > <http://127.0.0.1:8000/test/appadmin/update/db/company/1>None_02<http://127.0.0.1:8000/test/appadmin/update/db/company/2> > None_13 > <http://127.0.0.1:8000/test/appadmin/update/db/company/3>None_24<http://127.0.0.1:8000/test/appadmin/update/db/company/4> > None_05 > <http://127.0.0.1:8000/test/appadmin/update/db/company/5>None_16<http://127.0.0.1:8000/test/appadmin/update/db/company/6> > None_27 > <http://127.0.0.1:8000/test/appadmin/update/db/company/7>None_08<http://127.0.0.1:8000/test/appadmin/update/db/company/8> > None_19 <http://127.0.0.1:8000/test/appadmin/update/db/company/9>None_2 > > > db.py > db.define_table('company', > Field('company')) > > default.py > def index(): > inputs = [] > for i in range(0,3): > inputs.append(db.company.company.clone(name='%s_%s' % ( > db.company.company.name, i))) > form = SQLFORM.factory(*inputs) > if form.process().accepted: > for i in range(0,3): > db.company.insert(company='%s_%s' % (form.vars.company, i)) > elif form.errors: > response.flash = 'form has errors' > return dict(form=form) > > index.html > {{extend 'layout.html'}} > {{=form}} > > is there something wrong in my code above? > thank you > -- --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.