Ok, forget about it Massimo. I found why I get duplicated field name error.
Multiples tables in one form works, but I have a bizzard thing, see by your self : db.define_table('ref_fnaregistry', Field('fnaregistry_id','id'), Field('num_part1','string', length=20, notnull=True, requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))], required=True ), Field('num_part2','string', length=20, notnull=True, requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))], required=True ), Field('num_part3','string', length=20, notnull=True, requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))], required=True ), #migrate=False, sequence_name='ref_fnaregistry_fnaregistry_id_seq', format=lambda row: '%s-%s-%s'\ %(row.num_part1.rstrip(),row.num_part2.rstrip(),row.num_part3.rstrip())) # ref_vregistry db.define_table('ref_vregistry', Field('vregistry_id','id'), Field('vol_num','integer', notnull=True, requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))], required=True ), Field('vol_fnaregistry_id',db.ref_fnaregistry), #migrate=False, sequence_name='ref_vregistry_vregistry_id_seq', format='%(vol_num)s') db.ref_vregistry.vol_fnaregistry_id.requires = IS_IN_DB(db,'ref_fnaregistry.fnaregistry_id',db.ref_fnaregistry._format) # ref_tregistry db.define_table('ref_tregistry', Field('tregistry_id','id'), Field('tome_num','integer', notnull=True, requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))], required=True ), Field('vregistry_id',db.ref_vregistry), Field('tom_fnaregistry_id',db.ref_fnaregistry), #migrate=False, sequence_name='ref_tregistry_tregistry_id_seq', format='%(tome_num)s') db.ref_tregistry.vregistry_id.requires =\ IS_NULL_OR(IS_IN_DB(db,'ref_tregistry.vregistry_id',db.ref_tregistry._format)) db.ref_tregistry.tom_fnaregistry_id.requires =\ IS_NULL_OR(IS_IN_DB(db,'ref_fnaregistry.fnaregistry_id',db.ref_fnaregistry._format)) # ref_eregistry db.define_table('ref_eregistry', Field('eregistry_id','id'), Field('exp_num','string', length=255, notnull=True, requires=[IS_NOT_EMPTY(error_message=T('field can\'t be empty'))], required=True ), Field('tregistry_id',db.ref_tregistry), #migrate=False, sequence_name='ref_eregistry_eregistry_id_seq', format='%(exp_num)s') in ref_tregistry I can make relation with fnaregistry or vregistry... It was causing the problem... I changed the name of the fnaregistry_id for vol_fnaregistry_id and tom_fnaregistry_id that solve the duplicated field name problem and I can load input with this modified controller from the book : def create_all_at_once(): db.ref_vregistry.vol_fnaregistry_id.readable=False db.ref_vregistry.vol_fnaregistry_id.writable=False db.ref_tregistry.vregistry_id.readable=False db.ref_tregistry.vregistry_id.writable=False db.ref_tregistry.tom_fnaregistry_id.readable=False db.ref_tregistry.tom_fnaregistry_id.writable=False db.ref_eregistry.tregistry_id.readable=False db.ref_eregistry.tregistry_id.writable=False form = SQLFORM.factory(db.ref_fnaregistry,db.ref_vregistry,db.ref_tregistry,db.ref_eregistry) if form.accepts(request.vars): id = db.ref_fnaregistry.insert(**db.ref_fnaregistry._filter_fields(form.vars)) form.vars.vol_fnaregistry_id=id id = db.ref_vregistry.insert(**db.ref_vregistry._filter_fields(form.vars)) form.vars.vregistry_id=id id = db.ref_tregistry.insert(**db.ref_tregistry._filter_fields(form.vars)) form.vars.tregistry_id=id id = db.ref_eregistry.insert(**db.ref_eregistry._filter_fields(form.vars)) response.flash='Thanks for filling the form' return dict(form=form) But I have to find a way to by pass the double relation problem I have... If you have a idea... Maybe with list:reference multiple=True... But I don't like this workaround it so much, since I have to use postgres function in my SQL or relied entirely on web2py for query those tables... I prefer keep my schema as simple as possible so it can be queried with basic SQL syntax Richard On Tue, Feb 15, 2011 at 7:37 PM, Massimo Di Pierro < massimo.dipie...@gmail.com> wrote: > Can you provide an example of "form for many tables" this is not > something web2py supports out of the box so it depends. I can see > problems with it. > > On Feb 15, 3:08 pm, Richard Vézina <ml.richard.vez...@gmail.com> > wrote: > > Hello Massimo, > > > > Is there something wrong with this syntax : > > > > Field('table_id','id') > > sequence_name='table_table_id_seq' > > > > You introduced it, a couples of month ago... It works just fine with > > Postgres... But now I am facing problem. > > > > If I want to make one form for many tables, it is not possible since > those > > tables are sharing common id fields names for PK and FK. > > > > So I am stuck... > > > > I have to remane all my PK field "id" and pray that it not brakes > > anything... > > > > Did you anticipated this problem or have a solution? > > > > Thanks > > > > Richard >