diff --git a/tailbone/forms/renderers/common.py b/tailbone/forms/renderers/common.py index 43158ce3..c53a76c6 100644 --- a/tailbone/forms/renderers/common.py +++ b/tailbone/forms/renderers/common.py @@ -158,12 +158,13 @@ class EnumFieldRenderer(SelectFieldRenderer): """ Renderer for simple enumeration fields. """ - enumeration = {} + render_key = False - def __init__(self, arg): + def __init__(self, arg, render_key=False): if isinstance(arg, dict): self.enumeration = arg + self.render_key = render_key else: self(arg) @@ -174,8 +175,11 @@ class EnumFieldRenderer(SelectFieldRenderer): def render_readonly(self, **kwargs): value = self.raw_value if value is None: - return u'' - return self.enumeration.get(value, unicode(value)) + return '' + rendered = self.enumeration.get(value, unicode(value)) + if self.render_key: + rendered = '{} - {}'.format(value, rendered) + return rendered def render(self, **kwargs): opts = [(self.enumeration[x], x) for x in self.enumeration]