--- a/src/pyams_content/shared/form/field.py Fri Jul 26 12:59:07 2019 +0200
+++ b/src/pyams_content/shared/form/field.py Fri Jul 26 13:00:24 2019 +0200
@@ -67,13 +67,16 @@
def get_fields(self):
registry = get_global_registry()
- fields = []
for field in self.values():
if field.visible:
factory = registry.queryUtility(IFormFieldFactory, name=field.field_type)
if factory is not None:
- fields.append(factory.get_schema_field(field))
- return fields
+ yield factory.get_schema_field(field)
+
+ def find_fields(self, factory):
+ for field in self.values():
+ if field.field_type == factory:
+ yield field
@adapter_config(context=IFormFieldContainerTarget, provides=IFormFieldContainer)
@@ -187,12 +190,32 @@
field_factory = Decimal
+@utility_config(name='date', provides=IFormFieldFactory)
+class DateFieldFactory(BaseFormFieldFactory):
+ """Date field factory"""
+
+ label = _("Date")
+ weight = 6
+
+ field_factory = Date
+
+
+@utility_config(name='phone_number', provides=IFormFieldFactory)
+class PhoneNumberFieldFactory(BaseFormFieldFactory):
+ """Phone number field factory"""
+
+ label = _("Phone number")
+ weight = 10
+
+ field_factory = TextLine
+
+
@utility_config(name='mail', provides=IFormFieldFactory)
class MailFieldFactory(BaseFormFieldFactory):
"""Mail field factory"""
label = _("E-mail address")
- weight = 10
+ weight = 15
field_factory = MailAddressField
@@ -202,21 +225,11 @@
"""URI field factory"""
label = _("URI")
- weight = 11
+ weight = 20
field_factory = URI
-@utility_config(name='date', provides=IFormFieldFactory)
-class DateFieldFactory(BaseFormFieldFactory):
- """Date field factory"""
-
- label = _("Date")
- weight = 15
-
- field_factory = Date
-
-
class ValuesFieldFactory(BaseFormFieldFactory):
"""Values-based field factory"""
@@ -226,7 +239,7 @@
"""Choice field factory"""
label = _("Choice")
- weight = 20
+ weight = 30
field_factory = Choice
@@ -246,7 +259,7 @@
"""List field factory"""
label = _("List")
- weight = 51
+ weight = 40
field_factory = List