Ticket #5523: ukcountieslocalflavor-5523.diff

File ukcountieslocalflavor-5523.diff, 1.3 KB (added by David Reynolds, 16 years ago)

adding in the form widgets as suggested.

  • django/contrib/localflavor/uk/forms.py

    diff --git a/django/contrib/localflavor/uk/forms.py b/django/contrib/localflavor/uk/forms.py
    index 84d6c0e..23c4c79 100644
    a b  
    22UK-specific Form helpers
    33"""
    44
    5 from django.newforms.fields import RegexField
     5from django.newforms.fields import RegexField, Select
    66from django.utils.translation import ugettext
    77
    88class UKPostcodeField(RegexField):
    class UKPostcodeField(RegexField):  
    1717            max_length=None, min_length=None,
    1818            error_message=ugettext(u'Enter a postcode. A space is required between the two postcode parts.'),
    1919            *args, **kwargs)
     20
     21class UKCountySelect(Select):
     22    """
     23    A Select widget that uses a list of UK Counties/Regions as its choices.
     24    """
     25    def __init__(self, attrs=None):
     26        from uk_regions import UK_REGION_CHOICES
     27        super(UKCountySelect, self).__init__(attrs, choices=UK_REGION_CHOICES)
     28       
     29
     30class UKNationSelect(Select):
     31    """
     32    A Select widget that uses a list of UK Nations as its choices.
     33    """
     34    def __init__(self, attrs=None):
     35        from uk_regions import UK_NATIONS_CHOICES
     36        super(UKNationSelect, self).__init__(attrs, choices=UK_NATIONS_CHOICES)
     37 No newline at end of file
Back to Top