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 <d.as...@web.de> 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###

Reply via email to