How to edit boolean fields via one dropdown widget

38 views
Skip to first unread message

Horst Horst

unread,
Nov 14, 2021, 6:29:14 AM11/14/21
to web2py-users
I have a table with two boolean fields. All four combinations used to be meaningful, but now only three are.

I'd like to present the three options in one dropdown list instead of two checkboxes. Is this possible and how?

Jim S

unread,
Nov 15, 2021, 10:49:05 AM11/15/21
to web2py-users
I'd do that with a custom form (SQLFORM.factory).


-Jim

Horst Horst

unread,
Nov 15, 2021, 11:13:11 AM11/15/21
to web2py-users
Thanks for your reply, Jim. Unfortunately the table is actually auth_user, the boolean fields are extensions which I defined via

auth.settings.extra_fields[auth.settings.table_user_name] = [...]

Unless there's a very simple way to replace or customize the builtin user profile related funtions, I'd rather not like to touch that. I was hoping that I could define some kind of virtual field which serves as a front end to the two flags, but didn't see anything in the docs.

Clemens

unread,
Nov 16, 2021, 1:02:24 PM11/16/21
to web2py-users
If you are using SQLFORM (form = SQLFORM(...)), then you can add extra fields via form[0].insert(...). The extra fields can be addressed by their names via form.vars.<name> when you validate the form via form.validate().

Is this the right direction? If yes and you want more information how to do this, please let me know.

Best regards
Clemens
Reply all
Reply to author
Forward
0 new messages