Add "empty" option to enum field renderers, if field allows empty value
This commit is contained in:
parent
8d6c9854a3
commit
343f9bde1b
|
@ -209,6 +209,8 @@ class EnumFieldRenderer(SelectFieldRenderer):
|
||||||
|
|
||||||
def render(self, **kwargs):
|
def render(self, **kwargs):
|
||||||
opts = [(self.enumeration[x], x) for x in self.enumeration]
|
opts = [(self.enumeration[x], x) for x in self.enumeration]
|
||||||
|
if not self.field.is_required():
|
||||||
|
opts.insert(0, self.field._null_option)
|
||||||
return SelectFieldRenderer.render(self, opts, **kwargs)
|
return SelectFieldRenderer.render(self, opts, **kwargs)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue