you can do
db.define_table('x',
db.Field('y_id',db.y,requires=IS_IN_DB(db,'y.id','%(name)s'),
db.Field('name','string',requires=[
IS_NOT_EMPTY(),
IS_NOT_IN_DB(db(db.x.y_id==request.vars.y_id),'x.name')
]
),
)
Assuming the validator is only executing when a form is submitted
(i.e. request.vars.y_id is defined).
On Jun 27, 1:49 pm, weheh <[email protected]> wrote:
> db.define_table('x',
> db.Field('y_id',db.y,requires=IS_IN_DB(db,'y.id','%(name)s'),
> db.Field('name','string',requires=[
> IS_NOT_EMPTY(),
> IS_NOT_IN_DB(???????,'x.name')
> ]
> ),
> )
>
> The question is this: How to write the requires clause such that the
> x.name field is unique within the scope of the x.y_id? In other words,
> for a given x.y_id, all x.names must be unique. However, x.name may be
> repeated as long as the x.y_id is different for each occurrence of
> x.name.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---