PhoneNumber is a function proxying the actual formencode.national.USPhoneNumber Use that one or call the PhoneNumber function to get back the actual validator instance.
As all FancyValidator instances support a bunch of options I think it's actually more common and probably correct to use something like validator=Email(not_empty=True) and validator=PhoneNumber(not_empty=True) than to use All() with NotEmpty. On Thu, Jan 7, 2016 at 6:58 PM, Diego García <[email protected]> wrote: > Good morning! > I need to validate a field, it is to add phone. > > # -*- coding: utf-8 -*- > > import tw2.core as twc > from formencode.validators import FieldsMatch, NotEmpty, Email, PlainText, > PhoneNumber > from formencode.compound import All > import tw2.forms.widgets as twf > from tg import lurl > > class LeadForm(twf.Form): > class child(twf.ListLayout): > hover_help = True > name=twf.TextField(label=False,css_class='FormField', placeholder > =("Nombre*:"), validator=NotEmpty) > phone=twf.TextField(label=False, css_class='FormField', > placeholder=(u"Teléfono*:"), validator=All(PhoneNumber,NotEmpty)) > email=twf.TextField(label=False, css_class='FormField', > placeholder=(u"Correo electrónico*:"), validator=All(Email,NotEmpty)) > lp_type=twf.HiddenField() > event_id=twf.HiddenField() > c=twf.HiddenField() > m=twf.HiddenField() > s=twf.HiddenField() > action=lurl('/thanks') > buttons=[twf.SubmitButton('send',value = u'Enviar Información', > css_class='FormButton')] > id = "form" > > When I load the page I get the following error > > AttributeError: 'function' object has no attribute 'from_python' > > -- > You received this message because you are subscribed to the Google Groups > "TurboGears" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at https://groups.google.com/group/turbogears. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "TurboGears" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/turbogears. For more options, visit https://groups.google.com/d/optout.

