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)
def setUpClass(cls): fields.register("myfield", MyField)
def setUpClass(cls): fields.register("bad", BadField)
def setUpClass(cls): fields.register("good", GoodField)
def setUpClass(cls): fields.register('bad', BadField)
def setUpClass(cls): fields.register('good', GoodField)