For the record, I believe the problem is that because disabled form elements do not get submitted with the form, submission of a disabled boolean checkbox is interpreted the same as an unchecked boolean checkbox -- so even though SQLFORM.__init__ creates the widget with _checked=True, the FORM.accepts method ultimately sets _checked=None.
Anthony On Friday, April 1, 2016 at 11:59:00 PM UTC-4, Anthony wrote: > > Looks like a bug (please open a Github issue). In the meantime, see > http://stackoverflow.com/a/36369012/440323. > > Anthony > > On Friday, April 1, 2016 at 2:31:11 PM UTC-4, Jeremy Martin wrote: >> >> I have a simple piece of code: >> >> form = SQLFORM.factory(Field("readonly_field", writable=False, >> default="can't change") >> ,Field("some_field", requires=IS_LENGTH(10,5)) >> ,Field("some_flag", "boolean", writable=False, >> default=True)) >> >> if form.process().accepted: >> print("accepted") >> >> return dict(form=form) >> >> >> Note that the "some_flag" field is defaulted to "true". If the form is >> submitted successfully, everything happens as expected: the "some_field" is >> blank but the other two fields have their original defaulted values. >> >> Now, if the form fails validation, the "some_flag" checkbox is unchecked. >> The other read-only field still has its value. >> >> It should also be noted that using the "keepvalues" flag in the "process" >> function will persist the value in "some_field", but has no effect on >> whether the "some_flag" checkbox is checked. >> >> This looks like a bug, but if I'm doing something wrong I'm open to >> alternatives. >> >> -- 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 [email protected]. For more options, visit https://groups.google.com/d/optout.

