Friends,

   I don't know if it's the best way, but this solved my problem:

In controller:

def create_tabela_preco():
        form = crud.create(db.pampa_tabelapreco, next=URL(r = request,f =
'tabelas_preco'), onvalidation=valida_tabela_preco, message=T("Record
Created !"))
        return dict(form=form)

def valida_tabela_preco(form):
        categoria_cliente = form.vars['categoria']
        produto = form.vars['produto']
        query = (db.pampa_tabelapreco.categoria==categoria_cliente)&
(db.pampa_tabelapreco.produto==produto)
        rows = db(query).select(db.pampa_tabelapreco)
        if rows:
                form.errors = "Ja existe um preco com essa categoria de cliente 
e
este produto !"
        return form

In html:

        {{if form.errors:}}
                <div style="background-color: yellow; color: 
red;">{{=form.errors}}</
div>
        {{pass}}
        {{=form}}
--~--~---------~--~----~------------~-------~--~----~
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