{{extend 'layout.html'}} {{block sectionclass}}debug{{end}} {{ frm_trs = form.elements('tr') tbl_rows = [] for frm_tr in frm_trs: if frm_tr['_id'] != 'submit_record__row': fld_label = frm_tr.element('td.w2p_fl') fld_widget = frm_tr.element('td.w2p_fw')[0] fld_comment = frm_tr.element('td.w2p_fc')[0] lbls = fld_label.elements('label') lbl = '' if len(lbls) > 0: lbl = fld_label.elements('label')[0] lbl['_class'] = 'control-label' pass if fld_widget['_type'] == 'checkbox': fld_widget = LABEL(fld_widget, _class='checkbox') else: fld_widget = CAT(fld_widget, SPAN('', _class='help-inline')) pass if isinstance(fld_widget, SPAN): fld_widget['_role'] = 'asinput' pass tbl_row = DIV(lbl, DIV(fld_widget, TAG['SMALL'](fld_comment, _class='help-block'), _class='controls'), _class='control-group') tbl_rows.append(tbl_row) else: smt_btn = frm_tr.element('td.w2p_fw') btn = smt_btn.elements('input')[0] btn['_class'] = 'btn btn-primary' tbl_rows.append(DIV(btn, _class='controls')) pass pass form.element('table', replace=CAT(*tbl_rows)) form['_class'] = 'form-horizontal well well-small' import re if form.errors: for key, value in form.errors.iteritems(): inpt = form.element(_name=key) inpt_wrapper = inpt.parent if inpt_wrapper['_class'] == None or \ not "controls" in inpt_wrapper['_class']: inpt_wrapper = inpt_wrapper.parent pass inpt_wrapper.parent['_class'] += ' error' inpt_wrapper.element(_class=re.compile('help-inline'), replace=lambda me:SPAN(value, _class=me['_class'])) pass form.errors.clear() pass }}