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