show_if dependent on multiple fields

12 views
Skip to first unread message

Jim S

unread,
May 8, 2020, 2:07:46 PM5/8/20
to web2py-users
I'm using show_if to conditionally show fields on my form.  What a great feature!

Now however I've run into an instance where I have a field that I want displayed if either of two other fields is checked.

I know I can do show_if like this:

db.tablename.conditional_field.show_if = (db.tablename.checkbox_field_1 == True)


What I want to do is something like this (this code fails)

db.tablename.conditional_field.show_if = ((db.tablename.checkbox_field_1 == True) & (db.tablename.checkbox_field_2 == True))

Is there a way to string query expressions together with show_if?

-Jim

Jim S

unread,
May 8, 2020, 2:13:44 PM5/8/20
to web2py-users
That second block should have been an 'or' instead of 'and'

db.tablename.conditional_field.show_if = ((db.tablename.checkbox_field_1 == True) | (db.tablename.checkbox_field_2 == True))

-Jim
Reply all
Reply to author
Forward
0 new messages