On Wednesday, March 29, 2023 at 4:46:26 AM UTC-7 Dave S wrote: On Wednesday, March 29, 2023 at 4:10:19 AM UTC-7 Dave S wrote:
On Sunday, February 26, 2023 at 5:51:30 AM UTC-8 jeff...@gmail.com wrote: Is it possible to change the boolean field widget from checkbox to option with yes and no? How? I don't think you can do that with the default radio widget. This works: form3 = SQLFORM.factory( Field('bool', type = "string", default = False, \ um, that default should now be 'yes' or 'no', since the type isn't boolean requires=IS_IN_SET(['yes', 'no']), \ widget = lambda field, value: SQLFORM.widgets.radio.widget(field, value)), _name = "Georgeform") if form3.process(formname = "Georgeform", dbio = False, keepvalues = True).accepted: response.flash = "form3 bool %s" % ("T" if form3.vars.bool == 'yes' else 'F') else: response.flash = "form3 bool not set" but if you set the field type to boolean, you always get form3.vars.bool = True. Since I'm about to go to bed (as I said an hour ago), I'm not going to explore custom widgets, or using the INPUT() helper But synthesizing a boolean from the radio set is my idea of an obvious approach. The caveat is that if you're using SQLFORM instead of the factory, I'm not sure what will happen with the row posted to the table. Again, not before bed Ok, I won't *try* anything before bed, but I'd probably make the table def use a computed field for the boolean and have it not visible, and just add the radio set field to the table. /dps -- 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. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/01a081a1-80dc-4226-8137-9b8adefa9c1en%40googlegroups.com.