SQLFORM.accept is clobbering formstyle='bootstrap' when custom widgets are used

22 views
Skip to first unread message

Jeremy Field

unread,
Aug 31, 2014, 12:40:14 AM8/31/14
to web...@googlegroups.com
I believe this line in sqlhtml.py is disturbing the way formstyle_bootstrap displays custom widgets:
parent.components = [widget]

The older formstyles (table3cols, table2cols, etc) all wrap their controls within a dedicated tag, for example:
_controls = TD(controls, ...)
...
table.append(TR(_label, _controls, _help, _id=id))

In contrast, formstyle_bootstrap puts a help span as a sibling to the controls:
_help = SPAN(help, _class='help-block')
_controls = DIV(controls, _help, ...)
...
parent.append(DIV(label, _controls, ..., _id=id))

The result is that, when the form is submitted but has errors, i.e.:
  • form.accepts(...) returns False, and
  • fieldname is in request_vars,
the DIV which contained controls and _help now only contains the widget. The styling applied in formstyle_bootstrap is also lost, e.g.:
controls.add_class('span4')

A partial fix might be to wrap the controls in a redundant SPAN in formstyle_bootstrap:
_controls = DIV(SPAN(controls), _help, ...)
although this would not fix the styling problem.

Is this bug fixable while maintaining backward compatibility? Is there a fundamental impedance mismatch between the web2py and boostrap approaches to form layout? I have worked around the problem in my project to some extent with a custom formstyle, but am still affected by the styling problem.

Thanks for an otherwise glorious framework.

Regards,
Jeremy Field
Reply all
Reply to author
Forward
0 new messages