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<http://web2py.com/books/default/chapter/29/07#Database-validators> (near
the end of the section).
Anthony
On Saturday, December 29, 2012 4:02:09 PM UTC-5, Ilya wrote:
>
>
> *Issue:*
>
> 1. I have a field in a DB table like this:
>
> Field(*'home'*, 'reference home', requires=IS_IN_DB(db, 'home.id'),
> label='Home ID')
>
> 2. 'reference home' is a separate DB table like this:
>
> # A table to store home names
> db.define_table(*'home'*,
> Field('home_name', 'string', requires=[IS_NOT_EMPTY(),
> IS_NOT_IN_DB(db, 'home.home_name')]))
>
> 3. Now, when I have this in the controller:
>
> form = SQLFORM(db.user_home, fields=[*'home'*]).process()
>
> It shows the *'home'* field as a dropdown in the view
>
> *Questions:*
> *
> *
> a) How do I show the field (via SQLFORM) as a text field instead of as a
> dropdown?
>
> b) Maybe more generally, how do I choose how the DB field will be
> represented (dropdown, checkbox, field, etc.)? (since it seems to by
> default represent this field as a dropdown for me)
>
--