Document the EnumField form field type
This commit is contained in:
parent
a763662cd6
commit
43a90a237f
@ -174,6 +174,16 @@ class TimezoneField(SelectField):
|
|||||||
|
|
||||||
|
|
||||||
class EnumField(SelectField):
|
class EnumField(SelectField):
|
||||||
|
"""Field that allows selecting one value from an ``Enum`` class
|
||||||
|
|
||||||
|
:param enum_type: an ``Enum`` type
|
||||||
|
:type enum_type: type(Enum)
|
||||||
|
:param translations: translatable labels for enum values
|
||||||
|
:type translations: dict
|
||||||
|
:param args: passed verbatim to the constructor of `SelectField`
|
||||||
|
:param kwargs: passed verbatim to the constructor of `SelectField`
|
||||||
|
"""
|
||||||
|
|
||||||
def __init__(self, enum_type, translations, *args, **kwargs):
|
def __init__(self, enum_type, translations, *args, **kwargs):
|
||||||
if not issubclass(enum_type, Enum):
|
if not issubclass(enum_type, Enum):
|
||||||
raise TypeError('enum_type must be a subclass of Enum')
|
raise TypeError('enum_type must be a subclass of Enum')
|
||||||
|
Loading…
Reference in New Issue
Block a user