Ticket #12488: email_url_inputs.diff

File email_url_inputs.diff, 2.3 KB (added by Oliver Beattie, 15 years ago)
  • django/forms/fields.py

     
    2121from django.utils.formats import get_format
    2222
    2323from util import ErrorList, ValidationError
    24 from widgets import TextInput, PasswordInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget
     24from widgets import TextInput, PasswordInput, EmailInput, URLInput, HiddenInput, MultipleHiddenInput, FileInput, CheckboxInput, Select, NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput, SplitDateTimeWidget, SplitHiddenDateTimeWidget
    2525
    2626__all__ = (
    2727    'Field', 'CharField', 'IntegerField',
     
    410410    r')@(?:[A-Z0-9](?:[A-Z0-9-]{0,61}[A-Z0-9])?\.)+[A-Z]{2,6}\.?$', re.IGNORECASE)  # domain
    411411
    412412class EmailField(RegexField):
     413    widget = EmailInput
    413414    default_error_messages = {
    414415        'invalid': _(u'Enter a valid e-mail address.'),
    415416    }
     
    525526    r'(?:/?|/\S+)$', re.IGNORECASE)
    526527
    527528class URLField(RegexField):
     529    widget = URLInput
    528530    default_error_messages = {
    529531        'invalid': _(u'Enter a valid URL.'),
    530532        'invalid_link': _(u'This URL appears to be a broken link.'),
  • django/forms/widgets.py

     
    1616from urlparse import urljoin
    1717
    1818__all__ = (
    19     'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'PasswordInput',
     19    'Media', 'MediaDefiningClass', 'Widget', 'TextInput', 'PasswordInput', 'EmailInput', 'URLInput',
    2020    'HiddenInput', 'MultipleHiddenInput',
    2121    'FileInput', 'DateInput', 'DateTimeInput', 'TimeInput', 'Textarea', 'CheckboxInput',
    2222    'Select', 'NullBooleanSelect', 'SelectMultiple', 'RadioSelect',
     
    225225        if not self.render_value: value=None
    226226        return super(PasswordInput, self).render(name, value, attrs)
    227227
     228class EmailInput(Input):
     229    input_type = 'email'
     230
     231class URLInput(Input):
     232    input_type = 'url'
     233
    228234class HiddenInput(Input):
    229235    input_type = 'hidden'
    230236    is_hidden = True
Back to Top