the proper way to set labels in forms is

db.table.field.label=T("....")

On Sep 16, 9:20 am, Leandro - ProfessionalIT <[email protected]>
wrote:
> For example, in model I do this:
>
> db.define_table('unidades',
>     SQLField('sigla','string', length=3, default=''),
>     SQLField('descricao','string', length=150, default=''),
>     migrate=False)
> db.unidades.sigla.requires=IS_NOT_EMPTY()
> db.unidades.descricao.requires=IS_NOT_EMPTY()
> unidades_labels={'unidades.id':T('Código'),'sigla':T
> ('Sigla'),'descricao':T('Descrição')}
>
> in Controller, I do this to select (and work's fine):
>
> def unidades_lista():
>         atrr = { 'linkto' :  '/metalurgicabw/cadastros' }
>         items = crud.select(db.unidades, _id='list', fields=['unidades.id',
> 'sigla', 'descricao'], headers=unidades_labels, **atrr)
>         current_path= A('Cadastros de Unidades', _href=URL(r=request, f =
> 'unidades_lista'))
>         message_field = T('Listagem de Unidades !')
>         create_link = A('Create New Record', _href=URL(r=request, f =
> 'create_unidade'), _id="create_link")
>         return dict(message=T('Bem Vindo ao Cadastro de Unidades'), items =
> items, current_path=current_path, create_link=create_link,
> message_field=message_field)
>
> but in a create / update operation the labels don't work:
>
> def unidades():
>         id = int(request.args[0])
>         item = crud.update(db.unidades, id, next=URL(r = request,f =
> 'unidades_lista'))
>         message_field = T('Edição de Unidade !')
>         current_path= A('Cadastros de Unidades', _href=URL(r=request, f =
> 'unidades_lista'))
>         return dict(item=item, current_path=current_path,
> message_field=message_field)
>
> def create_unidade():
>         form = crud.create(db.unidades, next=URL(r = request,f =
> 'unidades_lista'), message=T("Record Created !"))
>         current_path= A('Cadastros de Unidades', _href=URL(r=request, f =
> 'unidades_lista'))
>         message_field = T('Inclusão de Unidade !')
>         return dict(form=form, current_path=current_path,
> message_field=message_field)
>
> How to resolve this question: Show the labels in Crud.create or
> Crud.update methods ?
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to