Hello! I have a table called *presupuesto *with a custom *format*:

db.define_table('presupuesto',
    Field('jar', db.jar, label='JAR'),
    Field('monto', 'decimal(11, 2)', label='Presupuesto inicial', 
requires=IS_NOT_EMPTY(error_message='Ingrese un monto para el 
presupuesto')),
    Field('monto_mensual', 'decimal(11, 2)', label='Presupuesto mensual', 
compute=lambda r: Decimal(r.monto)/Decimal('12')),
    Field('ano', 'integer', label='Año', 
requires=[IS_NOT_EMPTY(error_message='Ingrese el año'), 
IS_INT_IN_RANGE(1980, 2100, error_message='Año inválido')]),
    format=lambda record: '%s %s' % (record.jar.nombre, record.ano)
)

I'm using the following SQLFORM.factory in a view:

@auth.requires_login()
def control_gastos():
    form = SQLFORM.factory(
        Field('Presupuesto', requires=IS_IN_DB(db, db.presupuesto)),
        submit_button='Continuar',
        table_name='presupuesto',
    )
    form.element(_type='submit')['_class'] = 'btn btn-success'
    form.element('#presupuesto_Presupuesto')['_class'] = 'form-control'
    form.element('#presupuesto_Presupuesto')['_style'] = 'width: 100%'
    return dict(form=form)

Somehow, I was expecting that the records shown in the form were formatted 
as define in the table but that's not happening. Am I missing something?



Thanks,
César

-- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to