mirror of
https://github.com/Hopiu/wagtail.git
synced 2026-05-12 09:13:14 +00:00
Capitalize name nicely when using it as a fallback label.
This stops Multiple_words_with_underscores from creeping into the output, and eliminates the need for CSS text-transforms that Capitalize Every Word Like This.
This commit is contained in:
parent
9271e8f2a4
commit
8fd3d78e57
2 changed files with 7 additions and 8 deletions
|
|
@ -110,12 +110,12 @@ class Block(six.with_metaclass(BaseBlock, object)):
|
|||
Block.creation_counter += 1
|
||||
self.definition_prefix = 'blockdef-%d' % self.creation_counter
|
||||
|
||||
self.label = self.meta.label or ''
|
||||
|
||||
def set_name(self, name):
|
||||
self.name = name
|
||||
|
||||
@property
|
||||
def label(self):
|
||||
return self.meta.label or self.name
|
||||
if not self.meta.label:
|
||||
self.label = capfirst(name.replace('_', ' '))
|
||||
|
||||
@property
|
||||
def media(self):
|
||||
|
|
@ -301,7 +301,7 @@ class FieldBlock(Block):
|
|||
else:
|
||||
label_html = ''
|
||||
|
||||
widget_attrs = {'id': prefix, 'placeholder': self.label.title()}
|
||||
widget_attrs = {'id': prefix, 'placeholder': self.label}
|
||||
|
||||
if hasattr(widget, 'render_with_errors'):
|
||||
widget_html = widget.render_with_errors(prefix, value, attrs=widget_attrs, errors=errors)
|
||||
|
|
|
|||
|
|
@ -182,7 +182,7 @@
|
|||
padding:0;
|
||||
|
||||
label{
|
||||
text-transform:capitalize;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
&.required .field > label:after{
|
||||
|
|
@ -239,7 +239,6 @@
|
|||
padding:0;
|
||||
color:$color-grey-2;
|
||||
line-height:2.2em;
|
||||
text-transform:capitalize;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -412,7 +411,7 @@
|
|||
outline:$color-teal;
|
||||
|
||||
span{
|
||||
text-transform:capitalize;
|
||||
text-transform:none;
|
||||
white-space: pre-wrap;
|
||||
width:100%;
|
||||
display:block;
|
||||
|
|
|
|||
Loading…
Reference in a new issue