I think you look for something like db.table.field_2.compute=lambda r: request.vars.field_1
On May 11, 4:01 am, AsmanCom <[email protected]> wrote: > That would be a great solution, but i´ve to do this in model because i > am using the awesome JQGrid plugin (app.ebansoftware.net/ > editable_jqgrid/). > The dilemma is: > - I need to do this in the model > - I can`t get the vars from table.field.default (self-evident) > - I need a working IS_IN_DB(db,'table.id','table.name') validator and > label (for the JQGrid plugin) > - I can´t add an aditional validator (because IS_IN_DB +label don´t > show up right, when combined with other validators) > - The form must be visible to the user, so i can´t go with > table.field.compute > > So I think to implement this with Field default function is the right > approach? > But I need to catch the vars, compute someth. and Insert. > > Any ideas? > > On 10 Mai, 19:47, Iceberg <[email protected]> wrote: > > > Model: > > db.define_table('table_1', > > Field('field_1'), > > Field('field_2') > > ) > > > Controller: > > def index(): > > def magic(form): > > form.vars.field_2 = form.vars.field_1 > > form = SQLFORM(db.table_1) > > if form.accepts(request.vars, onvalidation=magic): > > pass # ok > > return {'form': form} > > > I did not test it. But it shows you the key of using onvalidation() > > trick. > > > Regards, > > Iceberg > > > On May11, 12:08am, AsmanCom <[email protected]> wrote: > > > > Hi, > > > > i want to do a simple task: > > > > def function_1(): > > > var_field_1=request.vars.field_1 > > > if var_field_1: > > > return var_field_1 > > > > db.define_table('table_1', > > > Field('field_1','string' ), > > > Field('field_2', default=function_1) > > > ) > > > > db.table_1.field_1.default='Autogenerated' > > > db.table_1.field_2.default='Autogenerated' > > > > I want to catch default vars from field 1 and insert them in field_2 > > > instead. > > > Is this possible? > > > > ###becomes interesting when combined, with IS_IN_DB and the > > > get_or_create function###

