class ProfileForm(ModelForm): wants_newsletter = forms.BooleanField(required=False, ) STATE_CHOICES = list(STATE_CHOICES) STATE_CHOICES.insert(0, ('', '---------')) state = USStateField(widget=forms.Select(choices=STATE_CHOICES, attrs={'class': 'form-control'})) zip_code = USZipCodeField(widget=forms.TextInput( attrs={'class': 'form-control'})) class Meta: model = UserProfile fields = ( 'address1', 'address2', 'city', 'state', 'zip_code', 'wants_newsletter', ) widgets = { 'address1': forms.TextInput(attrs={'class': 'form-control'}), 'address2': forms.TextInput(attrs={'class': 'form-control'}), 'city': forms.TextInput(attrs={'class': 'form-control'}), 'zip_code': forms.TextInput(attrs={'class': 'form-control'}) } def __init__(self, *args, **kwargs): super(ProfileForm, self).__init__(*args, **kwargs) self.fields[ 'wants_newsletter'].label = "Send me the monthly Free Law Project newsletter" for key in ['address1', 'city', 'state', 'zip_code']: self.fields[key].required = True
class ProfileForm(ModelForm): wants_newsletter = forms.BooleanField(required=False) STATE_CHOICES = list(STATE_CHOICES) STATE_CHOICES.insert(0, ("", "---------")) state = USStateField(widget=forms.Select(choices=STATE_CHOICES, attrs={"class": "form-control"})) zip_code = USZipCodeField(widget=forms.TextInput( attrs={"class": "form-control"})) class Meta: model = UserProfile fields = ( "address1", "address2", "city", "state", "zip_code", "wants_newsletter", ) widgets = { "address1": forms.TextInput(attrs={"class": "form-control"}), "address2": forms.TextInput(attrs={"class": "form-control"}), "city": forms.TextInput(attrs={"class": "form-control"}), "zip_code": forms.TextInput(attrs={"class": "form-control"}), } def __init__(self, *args, **kwargs): super(ProfileForm, self).__init__(*args, **kwargs) self.fields[ "wants_newsletter"].label = "Send me the monthly Free Law Project newsletter" for key in ["address1", "city", "state", "zip_code"]: self.fields[key].required = True
class ProfileForm(ModelForm): STATE_CHOICES = list(STATE_CHOICES) STATE_CHOICES.insert(0, ('', '---------')) state = USStateField( widget=forms.Select( choices=STATE_CHOICES, attrs={ 'class': 'form-control', 'autocomplete': 'address-level1', }, ), required=False, ) zip_code = USZipCodeField( widget=forms.TextInput(attrs={ 'class': 'form-control', 'autocomplete': 'postal-code', }), required=False, ) class Meta: model = UserProfile fields = ( 'employer', 'address1', 'address2', 'city', 'state', 'zip_code', 'wants_newsletter', 'barmembership', 'plaintext_preferred', ) widgets = { 'employer': forms.TextInput(attrs={ 'class': 'form-control', 'autocomplete': 'organization', }), 'barmembership': forms.SelectMultiple( attrs={'size': '8', 'class': 'form-control'} ), 'address1': forms.TextInput(attrs={ 'class': 'form-control', 'autocomplete': 'address-line1', }), 'address2': forms.TextInput(attrs={ 'class': 'form-control', 'autocomplete': 'address-line2', }), 'city': forms.TextInput(attrs={ 'class': 'form-control', 'autocomplete': 'address-level2', }), # 'wants_newsletter': forms.TextInput(attrs={'class': 'form-control'}), # 'plaintext_preferred': forms.TextInput(attrs={'class': 'form-control'}), }
from django import forms from localflavor.us.forms import USStateField, USZipCodeField from localflavor.us.us_states import STATE_CHOICES PHONE_RE = ( r"""(?P<prefix>\+?[\d\s\(\)\-]*)""" r"""(?P<area_code>\(?\d{3}\)?[\s\-\(\)]*)""" r"""(?P<first_three>\d{3}[\-\s\(\)]*)""" r"""(?P<last_four>\d{4}[\-\s]*)""" r"""(?P<extension>[\s\(,]*?ext[ .]*?\d{3,5})?""" r"""(?P<tty>\s*\(tty)?""" ) STATE_CHOICES = list(STATE_CHOICES) STATE_CHOICES.insert(0, ('', '---------')) class AgencyForm(forms.Form): slug = forms.CharField(widget=forms.HiddenInput()) # Description description = forms.CharField( max_length=500, required=False, widget=forms.Textarea(attrs={'rows': 3, 'class': 'description'})) # Public Liaison public_liaison_name = forms.CharField( label='Name', required=False, widget=forms.TextInput(attrs={'class': 'public_liaison_name'}))
class ProfileForm(ModelForm): STATE_CHOICES = list(STATE_CHOICES) STATE_CHOICES.insert(0, ("", "---------")) state = USStateField( widget=forms.Select( choices=STATE_CHOICES, attrs={ "class": "form-control", "autocomplete": "address-level1", }, ), required=False, ) zip_code = USZipCodeField( widget=forms.TextInput(attrs={ "class": "form-control", "autocomplete": "postal-code", }), required=False, ) class Meta: model = UserProfile fields = ( "employer", "address1", "address2", "city", "state", "zip_code", "wants_newsletter", "barmembership", "plaintext_preferred", ) widgets = { "employer": forms.TextInput(attrs={ "class": "form-control", "autocomplete": "organization", }), "barmembership": forms.SelectMultiple(attrs={ "size": "8", "class": "form-control" }), "address1": forms.TextInput(attrs={ "class": "form-control", "autocomplete": "address-line1", }), "address2": forms.TextInput(attrs={ "class": "form-control", "autocomplete": "address-line2", }), "city": forms.TextInput(attrs={ "class": "form-control", "autocomplete": "address-level2", }), }
from django import forms from localflavor.us.forms import USStateField, USZipCodeField from localflavor.us.us_states import STATE_CHOICES PHONE_RE = (r"""(?P<prefix>\+?[\d\s\(\)\-]*)""" r"""(?P<area_code>\(?\d{3}\)?[\s\-\(\)]*)""" r"""(?P<first_three>\d{3}[\-\s\(\)]*)""" r"""(?P<last_four>\d{4}[\-\s]*)""" r"""(?P<extension>[\s\(,]*?ext[ .]*?\d{3,5})?""" r"""(?P<tty>\s*\(tty)?""") PHONE_PATTERN = '(?:\(\d{3}\)|\d{3})[- ]?\d{3}[- ]?\d{4}' STATE_CHOICES = list(STATE_CHOICES) STATE_CHOICES.insert(0, ('', '---------')) class AgencyForm(forms.Form): slug = forms.CharField(widget=forms.HiddenInput()) # Description description = forms.CharField( max_length=500, required=False, widget=forms.Textarea(attrs={ 'class': 'agency_description', 'maxlength': 500 })) # Public Liaison public_liaison_name = forms.CharField( label='Name',