from django import forms
from django_countries.fields import CountryField
from django_countries.widgets import CountrySelectWidget
from .models import BillingAddress



PAYMENT_CHOICES =(
	('M', 'Mpesa'),
	('P', 'PayPal'),
	)

class CheckoutForm(forms.ModelForm):

    def __init__(self, *args, **kwargs):
        super(CheckoutForm, self).__init__(*args, **kwargs)
        for name in self.fields.keys():
            self.fields[name].widget.attrs.update({
                'class': 'form-control',                
                "id"   :  str("contact"+name),                              
                })
    class Meta:
        model = BillingAddress
        fields = ("__all__")

class CheckOutForm(forms.Form):
	postal_code         = forms.CharField(widget=forms.TextInput(attrs={'placeholder' : 'Postcode/ZIP'}))
	telephone_no        = forms.CharField(max_length=100, widget=forms.TextInput(attrs={'placeholder' : 'Telephone No'}))
	apartment_add       = forms.CharField(required=False, widget=forms.TextInput(attrs={'placeholder' : 'Apartment or Suite'}))
	country             = CountryField(
		blank_label='(select country)').formfield(widget=CountrySelectWidget())
	same_shipping_address= forms.BooleanField(required=False)
	save_info           = forms.BooleanField(required=False)
	payment_option      = forms.ChoiceField(widget=forms.RadioSelect,choices=PAYMENT_CHOICES)



