You should use field .clone() method instead of redefining fields... For represent the user_id by it username, you should specify the represent field like this in your IS_IN_DB() validator :
IS_IN_DB(db,db.auth_user.id, '%(username)s') Richard On Wed, Jan 13, 2016 at 7:36 PM, Tom Campbell <tomcampb...@gmail.com> wrote: > > > On Wednesday, January 13, 2016 at 3:38:56 PM UTC-8, Tom Campbell wrote: >> >> Creating a custom form that relates first name and last name fields to >> the db.auth_user's user_id field. In the form below the user ID shows as an >> integer in the dropdown but I'd like it to show as the user's name. How do >> I do that? >> >> form = SQLFORM.factory( >> >> Field('first_name', requires=IS_NOT_EMPTY()), >> Field('last_name', requires=IS_NOT_EMPTY()), >> Field('user_id', 'reference auth_user', requires=IS_IN_DB(db, >> db.auth_user.id)), >> fields=['first_name', 'last_name', 'user_id'], >> ) >> >> I also tried this, but it sill displayed as an integer: > Field('user_id', 'reference auth_user', > widget=SQLFORM.widgets.options.widget, requires=IS_IN_DB(db, > db.auth_user.id)), > > > -- > Resources: > - http://web2py.com > - http://web2py.com/book (Documentation) > - http://github.com/web2py/web2py (Source code) > - https://code.google.com/p/web2py/issues/list (Report Issues) > --- > 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 web2py+unsubscr...@googlegroups.com. > For more options, visit https://groups.google.com/d/optout. > -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- 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 web2py+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.