This still requires that you insert the id and not the name. If you
want a text field where you insert the "name" and that stores the id
into the field, assuming the name is unique you must define your own
validator for example

class IS_IN_TABLE_NAME:
    def __init__(self,table,error_message="name not in country.name'):
         self.error_message=error_message
         self.table=table
    def __call__(self,name):
         db=self.table._db
         rows=db(self.table.name==name).select(self.table.id)
         if not rows: return (name, self.error_message)
         return rows[0].id
    def formatter(self,id):
         return self.table[id].name

db.mytable.myfield.requires=IS_IN_TABLE_NAME(db.country)

On 22 Apr, 08:12, DenesL <denes1...@yahoo.ca> wrote:
> Drop downs are only created for non-list requires, e.g.
>
>  db.person.country.requires = [IS_IN_DB
> (db,'country.id','country.name')]
>
> should be
>
>  db.person.country.requires = IS_IN_DB
> (db,'country.id','country.name')
>
> Denes.
>
> On Apr 22, 1:57 am, dvid <d...@atlas.cz> wrote:
>
> > Massimo,
>
> > thank you for a blitz reply, the problem with insertion has been
> > solved.  :)
>
> > Please, have you any recommendation regarding the second thing - text
> > input field instead of select box for foreign key?
>
> > David
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to