As a workaround I have duck punched the SQLFORM.accepts() method to resolve 
the issue - however it is a kludge and I would prefer not to do this. 
Please see my code below.

###########################################################################
# Fix SQLFORM
###########################################################################
from gluon.sqlhtml import SQLFORM

def sqlform_accepts(
    self,
    request_vars,
    session=None,
    formname='%(tablename)s/%(record_id)s',
    keepvalues=None,
    onvalidation=None,
    dbio=True,
    hideerror=False,
    detect_record_change=False,
    __SUPERMETHOD__ = SQLFORM.accepts,
    **kwargs
):
    # get the classes from form fields
    f = self.field_parent
    field_classes = {k:map(lambda x: x['_class'] if '_class' in x.attributes 
else None, f[k].components if hasattr(f[k], 'components') else None) for k 
in f}
    
    # call original accepts() method
    result = __SUPERMETHOD__(self,
                             request_vars,
                             session=session,
                             formname=formname,
                             keepvalues=keepvalues,
                             onvalidation=onvalidation,
                             dbio=dbio,
                             hideerror=hideerror,
                             detect_record_change=detect_record_change,
                             **kwargs)
    
    # reassign classes to fields after the native accepts() method
    # wipes them out
    for k,v in field_classes.iteritems():
        for i,v in enumerate(field_classes[k]):
            if v and i < len(f[k].components):
                f[k].components[i]['_class'] = v
    
    return result

# duck punch the class
setattr(SQLFORM, 'accepts', sqlform_accepts)


-- 
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.

Reply via email to