[web2py] Re: DB data representation in a SQLFORM

2012-12-29 Thread Anthony
> > The presence of format='%(home_name)s also implies >db.other.home.represent = lambda id, row: '%(home_name)s' % db.home(id) > Note, the default "represent" attribute above is only set if you do NOT explicitly specify the "requires" attribute when defining the field. If you specify a "r

[web2py] Re: DB data representation in a SQLFORM

2012-12-29 Thread Massimo Di Pierro
Consider this db.define_table(*'home'*, Field('home_name', 'string', requires=[IS_NOT_EMPTY(), IS_NOT_IN_DB(db, 'home.home_name')]), format='%(home_name)s') db.define_table('other',Field(*'home'*, 'reference home', label='Home ID')) format='%(home_name)s' tells web2py how home is to be re

[web2py] Re: DB data representation in a SQLFORM

2012-12-29 Thread Anthony
More generally, to control the type of input used, see the book section on widgets . Anthony On Saturday, December 29, 2012 5:35:07 PM UTC-5, Anthony wrote: > > This IS_IN_DB validator is what gives you the dropdown -- if you don't > want t

[web2py] Re: DB data representation in a SQLFORM

2012-12-29 Thread Anthony
This IS_IN_DB validator is what gives you the dropdown -- if you don't want the dropdown, then you can put the validator in a list: Field('home', 'reference home', requires=[IS_IN_DB(db, 'home.id')], label='Home ID') This is mentioned in the book here