>    db.x.y_id.requires=IS_IN_SET(valid_y_ids)

IS_IN_SET takes a second parameter with the names you want to display
(or one parameter where the values and their displanames are provided
as a dictionary)

db.x.y_id.requires=IS_IN_SET(valid_y_ids, display_names)


On Mon, Jun 22, 2009 at 5:04 AM, weheh<[email protected]> wrote:
>
> Consider this:
>
> model:
>
> db.define_table('x',db.Field('y_id',db.y,requires=IS_NULL_OR(IS_IN_DB
> (db,'y.id','%(name)s'))))
>
> db.define_table('y',db.Field('name','string',requires=[IS_NOT_EMPTY
> (),IS_NOT_IN_DB(db,'y.name')]))
>
> controller:
>
> try:
>    records = db(db.x.id==int(request.args[1]))
>    valid_y_ids = [1,2,3]  # under normal circumstances, this is
> computed on the fly based on other db entries
>    db.x.y_id.requires=IS_IN_SET(valid_y_ids)
>    form=SQLFORM(db.x,record=records,submit_button='update')
> except:
>    form=SQLFORM(db.x,submit_button='new')
>
> What I want is that the requires clause in the try section should
> cause the form to display the names of entries in the y table that
> match the valid_y_ids list. What I get is just the id numbers in the
> valid_y_ids. How do I get the names, instead?
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to