hi

Has anyone had a simlilar requirement and used a different/better
approach that that described below?

I have 2 registration forms to cover my 2 user groups. Each is
prompted to register with a different subset of Auth User fields.

I've extended Auth to include the additional fields (e.g., Country,
Billing Country). The challenge is that for only one set of users are
some fields are Mandatory.

To achieve this I did the following:

1. set-up a table called iso3166 to hold a standard set of countries.

2. in my custom autrh user table include this statement:
db.Field('country', db.iso3166, requires=IS_NULL_OR(IS_INT_IN_RANGE(0,
1e100) ) )

I set 'requires' here otherwise the framework jumps in at this point
and will insist that this field has a validator to check that the
field is always set to an integer. My setting enables one of my
registration UIs to ignore the field.

3. in my controller...

for the form that prompts the user for country:
db.auth_user.country.requires = IS_IN_DB(db, db.iso3166.id, '%(country)
s', orderby=db.iso3166.country_order)

for the form that doesn't prompt for country:
db.auth_user.country.requires = IS_NULL_OR(IS_NOT_EMPTY())

So... I'm twisting existing validators to get the behaviour I want. In
step #3 "IS_NULL_OR(IS_NOT_EMPTY())" feels hacky but otherwise I'm
comfortable enough.

Constructive feedback welcomed.

Carl
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py-users" group.
To post to this group, send email to web2py@googlegroups.com
To unsubscribe from this group, send email to 
web2py+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to