Hello Niphlod, do I have to do that? I think I'm missing the point with the
*format* parameter of *define_table*.
On Monday, January 26, 2015 at 3:01:09 PM UTC-5, Niphlod wrote:
>
> where are you telling to SQLFORM.factory the representation of the record
> ?
>
> On Monday, January 26, 2015 at 5:09:31 PM UTC+1, César Bustíos Benites
> wrote:
>>
>> 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. It's only
>> showing IDs:
>>
>>
>> <https://lh6.googleusercontent.com/-HVtGNOVneTI/VMZm_thtOTI/AAAAAAAAYFs/YrDCU2mdVLI/s1600/Screenshot%2Bfrom%2B2015-01-26%2B11%3A09%3A18.png>
>>
>> What am I missing?
>>
>>
>> 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.