[autoform] Make RelationField.fromcardinality a class method factory
Instead of having the "RelationField" class hard-coded in this factory
method (thus preventing any subclass to properly use it), we make that
method a classmethod and instantiate the actual class instead of the
base one.
--- a/cubicweb/web/formfields.py Wed Aug 22 16:02:30 2018 +0200
+++ b/cubicweb/web/formfields.py Wed Aug 22 16:04:39 2018 +0200
@@ -1074,10 +1074,10 @@
:class:`~cubicweb.web.formwidgets.Select`.
"""
- @staticmethod
- def fromcardinality(card, **kwargs):
+ @classmethod
+ def fromcardinality(cls, card, **kwargs):
kwargs.setdefault('widget', fw.Select(multiple=card in '*+'))
- return RelationField(**kwargs)
+ return cls(**kwargs)
def choices(self, form, limit=None):
"""Take care, choices function for relation field instance should take