I want to add a custom attribute so that I can decide which customwidget has to be used for a form field connected to that field. Example:
db.define_table('person', Field('salutation', mycustomwidget='select2', label = T('Salutation'), requires=IS_IN_SET(GENDER), represent=lambda v, r: GENDER[v]), Field('first_name', label = T('First Name')), format = '%(last_name)s') I had no luck defining that custom attribute the way it is described in the book. How and and where would I define such a custom attribute 'mycustomwidget' for the table 'person' or even better for all tables? Adding attributes to fields and tables If you need to add custom attributes to fields, you can simply do this: 1 db.table.field.extra = {} "extra" is not a keyword ; it's a custom attributes now attached to the field object. You can do it with tables too but they must be preceded by an underscore to avoid naming conflicts with fields: 1 db.table._extra = {} -- 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.