Merge pull request #1118 from matclab/readonly-label

Add readonly class to labels of readonly fields and set padding to 0
This commit is contained in:
mdipierro
2015-12-04 10:43:17 -06:00
2 changed files with 21 additions and 8 deletions
@@ -320,3 +320,10 @@ li.w2p_grid_breadcrumb_elem {
.ie-lte8 div.flash{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#222222', endColorstr='#000000', GradientType=0 ); } .ie-lte8 div.flash{ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#222222', endColorstr='#000000', GradientType=0 ); }
.ie-lte8 div.flash:hover {filter:alpha(opacity=25);} .ie-lte8 div.flash:hover {filter:alpha(opacity=25);}
.ie9 #w2p_query_panel {padding-bottom:2px} .ie9 #w2p_query_panel {padding-bottom:2px}
.control-label.readonly{
padding-top:0px !important;
padding-right:0px !important;
}
+11 -5
View File
@@ -840,7 +840,7 @@ def formstyle_bootstrap(form, fields):
controls.add_class('span4') controls.add_class('span4')
if isinstance(label, LABEL): if isinstance(label, LABEL):
label['_class'] = 'control-label' label['_class'] += ' control-label'
if _submit: if _submit:
# submit button has unwrapped label and controls, different class # submit button has unwrapped label and controls, different class
@@ -890,7 +890,7 @@ def formstyle_bootstrap3_stacked(form, fields):
e.add_class('form-control') e.add_class('form-control')
if isinstance(label, LABEL): if isinstance(label, LABEL):
label['_class'] = 'control-label' label['_class'] += ' control-label'
parent.append(DIV(label, _controls, _class='form-group', _id=id)) parent.append(DIV(label, _controls, _class='form-group', _id=id))
return parent return parent
@@ -941,7 +941,7 @@ def formstyle_bootstrap3_inline_factory(col_label_size=3):
elif controls is None or isinstance(controls, basestring): elif controls is None or isinstance(controls, basestring):
_controls = P(controls, _class="form-control-static %s" % col_class) _controls = P(controls, _class="form-control-static %s" % col_class)
if isinstance(label, LABEL): if isinstance(label, LABEL):
label['_class'] = 'control-label %s' % label_col_class label['_class'] += ' control-label %s' % label_col_class
parent.append(DIV(label, _controls, _class='form-group', _id=id)) parent.append(DIV(label, _controls, _class='form-group', _id=id))
return parent return parent
@@ -1187,6 +1187,14 @@ class SQLFORM(FORM):
label = LABEL(label, label and sep, _for=field_id, label = LABEL(label, label and sep, _for=field_id,
_id=field_id + SQLFORM.ID_LABEL_SUFFIX) _id=field_id + SQLFORM.ID_LABEL_SUFFIX)
cond = readonly or \
(not ignore_rw and not field.writable and field.readable)
if cond:
label['_class'] = 'readonly'
else:
label['_class'] = ''
row_id = field_id + SQLFORM.ID_ROW_SUFFIX row_id = field_id + SQLFORM.ID_ROW_SUFFIX
if field.type == 'id': if field.type == 'id':
self.custom.dspval.id = nbsp self.custom.dspval.id = nbsp
@@ -1215,8 +1223,6 @@ class SQLFORM(FORM):
default = field.default default = field.default
if isinstance(default, CALLABLETYPES): if isinstance(default, CALLABLETYPES):
default = default() default = default()
cond = readonly or \
(not ignore_rw and not field.writable and field.readable)
if default is not None and not cond: if default is not None and not cond:
default = field.formatter(default) default = field.formatter(default)