Thank you Dave S, i figured the IS_IN_DB() approach wouldn't be the best 
solution, i went with another approach which has me stuck too, when you 
have time please look at it & see how you can help me
* https://groups.google.com/forum/#!topic/web2py/MeQEA9vB-Vc 
<https://groups.google.com/forum/#!topic/web2py/MeQEA9vB-Vc>*

Mostwanted


On Monday, March 18, 2019 at 11:04:52 PM UTC+2, Dave S wrote:
>
>
>
> On Saturday, March 16, 2019 at 2:18:03 AM UTC-7, mostwanted wrote:
>>
>>
>> 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.
>>
>
> Why would it be a link?   It's a pass/fail check, as "validator" suggests.
>
>  I think you may find some help in this other thread:
> <URLhttps://groups.google.com/d/msg/web2py/K7PWmfCD6Gk/cMAivRElBwAJ>
> but it's doing something different than just being a validator.
>
> /dps
>
>

-- 
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.

Reply via email to