Hello my friends, as I did not find anything in the international and national forums and no solution on the internet, I decided to post my question. I have the following table structure:
## DB models.py db.define_table( 'pessoas' ,Field('pes_nome_razao_social' ,notnull=True ,label=T("Nome") ,requires=IS_NOT_EMPTY() ) ,Field('pes_apelido',label=T("Apelido/Nome Fantasia")) ,Field('pes_cpf_cnpj',label=T("CPF/CNPJ"),unique=True) ,Field('pes_rg_ie',label=T("RG/I.E.")) ,Field('pes_created_on','datetime', label=T("Created On")) ,Field('pes_notas','text',label=T("Notas") ) ,Field('pes_tipo','string',length=20,label=T("Tipo") ) # ???? ,format="%(id)d - %(pes_nome_razao_social)s (%(pes_apelido)s)" ) db.define_table( 'clientes' ,Field('pessoa_id','reference pessoas',unique=True) ,Field('profissao','string') ,format="%(pessoa_id)s" ) ## controller if len(request.args) == 1: pessoa = db(db.pessoas.id == request.args(0)).select().first() cliente = db(db.clientes.pessoa_id == request.args(0)).select().first() # record = dict(pessoa.as_dict(), **cliente.as_dict()) form = SQLFORM.factory( db.pessoas, db.clientes, record=record ) form.elements('#no_table_pes_nome_razao_social')[0]['_placeholder'] = 'Nome ou Razão Social' if form.accepts(request,session): form.vars.pessoa_id=request.args(0) cliente.update_record(**db.clientes._filter_fields(form.vars)) form.vars.id=request.args(0) pessoa.update_record(**db.pessoas._filter_fields(form.vars)) response.flash=T('Thanks for filling the form') elif form.errors: response.flash=T('Erros no form') else: response.flash = "Me preencha" else: form = SQLFORM.factory(db.pessoas,db.clientes) form.elements('#no_table_pes_nome_razao_social')[0]['_placeholder'] = 'Nome ou Razão Social' if form.vars: id = db.pessoas.insert(**db.pessoas._filter_fields(form.vars)) form.vars.pessoas=id id = db.clientes.insert(**db.clientes._filter_fields(form.vars)) response.flash=T('Thanks for filling the form') return dict(form=form,url=url,clientes=classe) Using SQLFORM.factory I can bind data from a query to the factory, however when I run the submit in form I get a duplicate error and so it does not update the data, I know I could use a manual solution to work around the problem, but How do I do this without losing validate (), accpets () and process (), since I can validate the fields magically with a ready function? -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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/d/optout.