예제 #1
0
    def register_field(self, field_type, cls):
        from wagtailstreamforms import fields

        fields.register(field_type, cls)
        try:
            yield
        finally:
            fields._fields[field_type].remove(cls)
            ],
            icon=self.icon,
            label=self.label,
        )


FIELD_MAPPING = {
    "singleline": SingleLineTextField,
    "multiline": MultiLineTextField,
    "date": DateField,
    "datetime": DateTimeField,
    "email": EmailField,
    "url": URLField,
    "number": NumberField,
    "dropdown": DropdownField,
    "radio": RadioField,
    "checkboxes": CheckboxesField,
    "checkbox": CheckboxField,
    "hidden": HiddenField,
    "singlefile": SingleFileField,
    "multifile": MultiFileField,
}

enabled_fields = get_setting("ENABLED_FIELDS")

for field_name in enabled_fields:
    cls = FIELD_MAPPING.get(field_name, None)
    if not cls:
        raise KeyError("Field with name '%s' does not exist" % field_name)
    register(field_name, cls)
예제 #3
0
 def setUpClass(cls):
     fields.register("myfield", MyField)
예제 #4
0
 def setUpClass(cls):
     fields.register("bad", BadField)
예제 #5
0
 def setUpClass(cls):
     fields.register("good", GoodField)
예제 #6
0
 def setUpClass(cls):
     fields.register('bad', BadField)
예제 #7
0
 def setUpClass(cls):
     fields.register('good', GoodField)