SQLFORM widget IS_IN_SET translation

38 views
Skip to first unread message

rāma

unread,
Jul 25, 2018, 12:40:12 AM7/25/18
to web2py-users

I could do this in SQLFORM readonly mode:


However, how do you make SQLFORM to show the translations in edit mode. Do you have to modify the widget? How?

Thank you.

Anthony

unread,
Jul 25, 2018, 7:58:48 AM7/25/18
to web2py-users
You can specify labels associated with the values of an IS_IN_SET validator in one of three ways:

values = ['list', 'of', 'values']

# As a dictionary in {value: label, ...} form:
IS_IN_SET
({value: T(value) for value in values})

# As a list of tuples in (value, label) form:
IS_IN_SET
([(value, T(value)) for value in values])

# Using the "labels" argument.
IS_IN_SET
(values, labels=[T(value) for value in values])

Anthony

rāma

unread,
Jul 31, 2018, 11:38:24 PM7/31/18
to web2py-users
Thank you!
Reply all
Reply to author
Forward
0 new messages