assuming db.define_table('person',Field('fullname')) db.define_table('thing',Field('name'),Field('belongsto','reference person'))
you can define a function to capitalized a name def capitalize(name): return ' '.join(t.capitalize() for t in (name or '').split()) You can use to change the representation of name db.person.fullname.represent = lambda name,row: capitalize(name) If you want to store fullname capitalized you can create a validator instead class CAPITALIZE(object): def __call__(self,name): return ' '.join(t.capitalize() for t in (name or '').split()) db.person.fullname.requires=CAPITALIZE For the references you can do db.thing.belongsto.requires=IS_IN_DB(db,db.person.fullname) Instead of a dropdown you may want an autocomplete widget. db.thing.belongsto.widget = SQLFORM.widgets.autocomplete(request,db.person.fullname, db.person.id) Putting all together: db.define_table('person',Field('fullname')) db.define_table('think',Field('name'),Field('belongsto','reference person')) class CAPITALIZE(object): def __call__(self,name): return ' '.join(t.capitalize() for t in (name or '').split()) db.person.fullname.requires=CAPITALIZE db.thing.belongsto.widget = SQLFORM.widgets.autocomplete(request,db.person.fullname, db.person.id) Mind that if somebody is called "McDonald O'Neil" it would become " Mcdonald O'neil". Are you sure that is what you want? On Sunday, 16 December 2012 18:55:17 UTC-6, Dave Cenker wrote: > > I first must say that I have developed 2 different web applications using > Django in the past and I am very impressed and encouraged by what web2py > can offer to the web framework community. However, I am having trouble > carrying out a seemingly simple task without much ado after reviewing all > the documentation and traditional "googling" methods. > > Suppose I have a database table with a field named 'fullName'. When the > user submits a crud.create form with the data 'jOhN DoE', I would like for > this entry to be saved into the database as 'John Doe' (i.e. - title case). > In addition, I would like to be able to use the IS_IN_DB requirement > validator to disallow any variant of this entry to be entered in the > future. For example, if a user enters 'john doe', 'JOHN DOE', or 'JoHn > DoE', they should all be recognized as an entry that is already in the > database (i.e. - I would like a case insensitive check). > > I have tried to use the represent attribute on the field, however that > doesn't seem to affect the actual data that is saved in the database. I > have tried to use a custom onvalidation function, but it doesn't seem to > work well either. The only way I have seen that really seems to work is > having a separate database field (i.e. - two fields for the same database > object). Has anyone run into this situation and found a more eloquent > solution? > > Thanks in advance for any help you can provide! > > Dave > > --