you can do as you did with the hotels (i.e. passing a queryset already 
filtered instead of a table to the IS_IN_DB) or create a dict holding a few 
cities with as the key the id of the city and the value the name of it.

On Thursday, March 7, 2013 3:52:24 PM UTC+1, José Manuel López Muñoz wrote:
>
> Hi, 
> I'm trying to populate a drop down menu of a form like this:
> def createOffer():
>     hotelesUsuario=db(db.Hotel.managerID == auth.user_id)
>     db.Offer.hotel.requires=IS_IN_DB(hotelesUsuario,'Hotel.id','%(name)s')
>     form = SQLFORM(db.Offer)
>
> This is my Offer table:
>
>     db.define_table('Offer',
> SQLField('created_on', 'datetime', label="Día de creación de la oferta", 
> writable=False, default=request.now),
>                 SQLField('valid_from_date', 'datetime', label="Oferta 
> desde el día", default = request.now), 
>                 SQLField('valid_to_date', 'datetime', label="Oferta hasta 
> el día", default = request.now),
>                 SQLField('selected','boolean', default=False, 
> readable=False, writable=False),  
>                 SQLField('city',db.City, label="Ciudad"), 
>                 SQLField('hotel',db.Hotel),
>                 SQLField('num_rooms', label="N√∫mero de habitaciones", 
> default="1"),
>                 format="%(id)s")
>
> I want to populate the DropDown menu "city" with some cities (not all the 
> cities, like now) in my database
> How can I do it?
> form.var.city = ¿?¿? 
>
> I have tried many things but is clear I don't know how to do it. 
>
> Any help will be very appreciated :)
>

-- 

--- 
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/groups/opt_out.


Reply via email to