The following is a proposed patch to sqlhtml.py so that record fields
of type 'boolean' are added as hidden form fields if they are not
already included in the form.  In this way, the status of a checked/
true field is maintained even if the field is not included in the form
as a checkbox.

In the __init__ method, replace:

        if record:
            self.components=[TABLE(*xfields),INPUT
(_type='hidden',_name='id',_value=record['id'])]
        else: self.components=[TABLE(*xfields)]

...with...

        # Note: any record fields to be hidden must be included as a
component.
        # Hidden fields added as attributes are not validated/stored.
        self.components=[TABLE(*xfields)]
        if record:
            self.components.append(INPUT
(_type='hidden',_name='id',_value=record['id']))
            for field in self.table.fields:
                if not field in self.fields and \
                       self.table[field].type=='boolean' and record
[field]==True:
                    self.components.append(INPUT
(_type='hidden',_name=field,_value='ON'))

If a developer is customizing a form then IMHO it must be up to the
developer to be aware that boolean fields not included in the form
must be preserved by creating the appropriate hidden fields.  I cannot
see how this can be done automatically as web2py doesn't know which
fields have been left out of the custom view (without a lot of work
parsing the view).
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"web2py Web Framework" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/web2py?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to