class ConfigFormField(JSONFormField): def __init__(self, *args, **kwargs): super(ConfigFormField, self).__init__(*args, **kwargs) self.label = kwargs.get('label', _('Configuration')) self.widget = ConfigWidget() def set_config(self, config): self.config = config self.widget.add_config_widgets(config) def clean(self, value): value = super(ConfigFormField, self).clean(value) for name, param in self.config.items(): if not param.is_valid(value.get(name, None)): raise ValidationError(_('Error in "%(name)s" field') % {'name': param.label}) return value
class ConfigFormField(JSONFormField): def __init__(self, *args, **kwargs): super(ConfigFormField, self).__init__(*args, **kwargs) self.label = kwargs.get('label', _('Configuration')) self.widget = ConfigWidget() def set_config(self, config): self.config = config self.widget.add_config_widgets(config) def clean(self, value): value = super(ConfigFormField, self).clean(value) for name, param in self.config.items(): if not param.is_valid(value.get(name, None)): raise ValidationError( _('Error in "%(name)s" field') % {'name': param.label}) return value
def __init__(self, *args, **kwargs): super(ConfigFormField, self).__init__(*args, **kwargs) self.label = kwargs.get('label', _('Configuration')) self.widget = ConfigWidget()