Hello How do i implement these conditional fields in a custom auth table? I tried the following but does not seem to hide the grade field.
#Start of definition of custom Auth tables to be used instead of the default ones. auth = Auth(db) db.define_table(auth.settings.table_user_name, Field('role', 'string', requires=IS_IN_SET(['teacher', 'principal', 'head of dept', 'secretary', 'school board'])), Field('grade', 'string'), Field('first_name', length=128, default=''), Field('last_name', length=128, default=''), Field('date_of_birth', 'date', length=128), Field('national_id', length=128, label='Birth Registration No or ID_No'), Field('postal_address', length=128), Field('username', length=128, default=''), Field('password', 'password', length=512, readable=False, label='Password'), Field('registration_key', length=512, writable=False, readable=False, default=''), Field('reset_password_key', length=512, writable=False, readable=False, default=''), Field('registration_id', length=512, writable=False, readable=False, default='')) #get the custom_auth_table custom_auth_table = db[auth.settings.table_user_name] custom_auth_table.grade.show_if=custom_auth_table.role.belongs(('teacher','principal','head of dept')) custom_auth_table.last_name.requires = IS_NOT_EMPTY(error_message=auth.messages.is_empty) custom_auth_table.password.requires = [IS_STRONG(), CRYPT()] custom_auth_table.username.requires = IS_NOT_IN_DB(db, custom_auth_table.username, error_message='User name already in use, please choose another name') #custom_auth_table.parent_cell_no.requires = IS_MATCH('^\d{3}-\d{7}$',error_message='Enter a cellphone number like this: 081-1234567') auth.settings.table_user = custom_auth_table #Tell auth to use custom_auth_table auth.define_tables() #End of definition of custom Auth tables On Tuesday, June 4, 2013 at 10:55:31 PM UTC+2, Ramos wrote: > > Show if =visible when > No dia 04/06/2013 21:51, "Niphlod" <nip...@gmail.com <javascript:>> > escreveu: > >> it works, but a few hiccups with the examples posted.... >> >> def index1(): >> """ shows bb only if aa is checked """ >> db.define_table('thing', Field('aa','boolean'),Field('bb')) >> db.thing.bb.show_if = db.thing.aa==True >> form = SQLFORM(db.thing) >> return locals() >> >> def index2(): >> """ shows bb only when aa is not set to "x" """ >> db.define_table('thing', Field('aa'),Field('bb')) >> >> db.thing.aa.requires=IS_IN_SET(('x','y','z')) >> db.thing.bb.show_if = >> db.thing.aa!='x' >> form = SQLFORM(db.thing) >> return locals() >> >> def index3(): >> """ shows bb only when one types "x" or "y" in aa""" >> db.define_table('thing', Field('aa'),Field('bb')) >> db.thing.bb.show_if = db.thing.aa.belongs(('x','y')) >> form = SQLFORM(db.thing) >> return locals() >> >> def index4(): >> """ shows bb only when one types "abcd" in aa""" >> db.define_table('thing', Field('aa'),Field('bb')) >> db.thing.bb.show_if = db.thing.aa.contains('abcd') >> form = SQLFORM(db.thing) >> return locals() >> >> -- >> >> --- >> 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+un...@googlegroups.com <javascript:>. >> For more options, visit https://groups.google.com/groups/opt_out. >> >> >> > -- 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.