Renamed form input class
authorThierry Florac <tflorac@ulthar.net>
Fri, 26 Jul 2019 15:39:58 +0200
changeset 453 d5f2be8c16ad
parent 452 df3f13ea95cc
child 454 90b0f5d3f2df
Renamed form input class
src/pyams_default_theme/shared/form/__init__.py
--- a/src/pyams_default_theme/shared/form/__init__.py	Fri Jul 26 13:13:44 2019 +0200
+++ b/src/pyams_default_theme/shared/form/__init__.py	Fri Jul 26 15:39:58 2019 +0200
@@ -45,7 +45,7 @@
 RECAPTCHA_FIELD_NAME = 'g-recaptcha-response'
 
 
-class FormFieldContainerDisplayForm(AddForm):
+class FormFieldContainerInputForm(AddForm):
     """Form fields container display form"""
 
     @property
@@ -78,13 +78,13 @@
         return field.Fields(*tuple(get_fields()))
 
     def updateActions(self):
-        super(FormFieldContainerDisplayForm, self).updateActions()
+        super(FormFieldContainerInputForm, self).updateActions()
         if 'submit' in self.actions:
             self.actions['submit'].title = II18n(self.context).query_attribute('submit_label',
                                                                                request=self.request)
 
     def updateWidgets(self, prefix=None):
-        super(FormFieldContainerDisplayForm, self).updateWidgets(prefix)
+        super(FormFieldContainerInputForm, self).updateWidgets(prefix)
         for widget in self.widgets.values():
             if widget.field.__name__ == CSRF_FIELD_NAME:
                 widget.name = CSRF_FIELD_NAME
@@ -107,6 +107,7 @@
             if errors:
                 self.status = self.formErrorsMessage
             else:
+                # remove custom data fields from handler data
                 if CSRF_FIELD_NAME in data:
                     del data[CSRF_FIELD_NAME]
                 if self.context.use_captcha:
@@ -129,7 +130,7 @@
                 handler.handle(form, data)
 
 
-@adapter_config(context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldContainerDisplayForm),
+@adapter_config(context=(IFormFieldContainerTarget, IPyAMSLayer, FormFieldContainerInputForm),
                 provides=IFormHelp)
 class FormFieldContainerDisplayFormHelp(FormHelp):
     """Form field container display form help adapter"""
@@ -147,7 +148,7 @@
 
 
 @viewlet_config(name='recaptcha', context=IFormFieldContainerTarget, layer=IPyAMSDefaultLayer,
-                view=FormFieldContainerDisplayForm, manager=IFormSuffixViewletsManager)
+                view=FormFieldContainerInputForm, manager=IFormSuffixViewletsManager)
 @template_config(template='templates/recaptcha.pt', layer=IPyAMSDefaultLayer)
 class FormCaptchaViewlet(Viewlet):
     """Form captcha viewlet"""
@@ -168,7 +169,7 @@
 
     def __init__(self, context, request):
         super(FormFieldContainerRenderer, self).__init__(context, request)
-        self.input_form = FormFieldContainerDisplayForm(context, self.request)
+        self.input_form = FormFieldContainerInputForm(context, self.request)
 
     def update(self):
         super(FormFieldContainerRenderer, self).update()
@@ -186,7 +187,7 @@
 
     def __init__(self, context, request):
         super(FormSubmitPage, self).__init__(context, request)
-        self.input_form = FormFieldContainerDisplayForm(context, self.request)
+        self.input_form = FormFieldContainerInputForm(context, self.request)
 
     def update(self):
         super(FormSubmitPage, self).update()