I am new in Web2py.

I have the current requiment 

I need to create a Dropdownlist where in the user can select a value from 

the dropdownlist or type the value in. 

The Dropdownlist values are storedin a database table.

Examplee:

my Form looks like this one:

"Where do you come from?": Dropdown lists the available cities, if your 

city is not found type in your city.


I tried this code:

Field('City', requires = IS_IN_DB(db,db.city.id,'%(city)s')

With this code i can not enter a new city if it is missing in the 

database.

I can only select the available cities in the database. 


Full-Code:


*Model:*

db.define_table('city',Field('name',type='string',length=100,required=True
,notnull=True, ondelete='SET NULL',unique=True),format='%(name)s')

db.define_table('person',Field('name',type='string',length=100,required=Tr

ue,notnull=True, ondelete='SET NULL',unique=True),
Field('city_id','reference city',required=True,notnull=True,label='City'),

format='%(name)s')

db.person.city_id.requires=IS_IN_DB(db,'city.id' ,'%(city)s')

*Controller:*

def person():

     return 
dict(grid=sqlform.grid(db.person,create=True,editable=True,deletable=True))



*View:*{{extend 'layout.html'}}
...
<div class="row">

  <div class="col-md-12">

     {{pass}}

    {{=grid}}

  </div>
</div>

-- 
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
--- 
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to web2py+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/web2py/643ad187-25e5-4241-8c0d-c4a5f0d3ad93%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to