Updated "ajax_config" decorator
authorThierry Florac <thierry.florac@onf.fr>
Fri, 08 Jun 2018 10:52:49 +0200
changeset 109 48697c7b632c
parent 108 87ee710b7639
child 110 303800c113f2
Updated "ajax_config" decorator
src/pyams_form/form.py
--- a/src/pyams_form/form.py	Thu Jun 07 14:08:39 2018 +0200
+++ b/src/pyams_form/form.py	Fri Jun 08 10:52:49 2018 +0200
@@ -721,6 +721,12 @@
             # Create new AJAX form and register view
             base = settings.pop('base')
             new_class = type('AJAX' + ob.__name__, (base, ob), cdict)
+            try:
+                # check if current form is overriding "get_ajax_output" method
+                if ob.get_ajax_output.__qualname__.startswith(ob.__name__ + '.'):  # redefined method
+                    new_class.get_ajax_output = ob.get_ajax_output
+            except AttributeError:
+                pass
 
             if 'implementer' in settings:
                 implementer = settings.pop('implementer')