Hi guys, i am trying out the IS_IN_DB() validator for the first time, in my
research i cant really find out what i am looking for so i was hoping
someone with better understanding would assist me. I have 2 tables, one for
locations and the other for people and where they come from, I have created
a drop down menu from the locations table using the IS_IN_DB() validator,
initially the index page displays the drop down list locations and all the
registered people, what i want is that when one selects a location from the
drop down i should have only the people from that location now displayed,
not everyone like initially.
*MODEL CODE:*
*db.define_table('locations', Field('name'),
format='%(name)s')db.define_table('people', Field('name'),
Field('surname'), Field('home', 'reference
locations'))CONTROLLER CODE:*
def index():
people=db().select(db.people.ALL)
location=db().select(db.locations.ALL)
form=SQLFORM.factory(Field('city', requires=IS_IN_DB(db, 'locations.id',
'%(name)s',zero='--Select a location--'), label=SPAN('', _style="font-weight:
bold;")))
*VIEW CODE:*
*{{extend 'layout.html'}}<h3> SELECT LOCATION</h3>{{=form}}<br /><hr
/>{{for people in people:}}PERSON DETAILS<br />Person: {{=people.name}}
{{=people.surname}}<br />Location: {{=people.home.name}}<hr />{{pass}}*
This is a s far as i can go! If the drop down list form IS_IN_DB()
validator was like a link i would know what do but its not. Please help me.
Regards
Mostwanted
--
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 [email protected].
For more options, visit https://groups.google.com/d/optout.