Skip to content

Instantly share code, notes, and snippets.

@yunti
Created November 17, 2017 12:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yunti/8c091cd446082eb1208e076594fc2439 to your computer and use it in GitHub Desktop.
Save yunti/8c091cd446082eb1208e076594fc2439 to your computer and use it in GitHub Desktop.
crispy form no error with bootstrap beta
from django import forms
from localflavor.gb.forms import GBPostcodeField
from crispy_forms.helper import FormHelper
from crispy_forms.layout import Submit, Layout, Div, Field, HTML, MultiWidgetField, Fieldset
class PostcodeForm(forms.Form):
postcode = GBPostcodeField(label='Please enter your postcode',
error_messages={'invalid': 'Please enter a valid postcode'})
def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
self.helper = FormHelper(self)
self.helper.label_class = 'sr-only'
self.helper.form_tag = False
self.helper.layout = Layout(
PrependedText('postcode', '<i class="fa fa-home"></i>', placeholder="Postcode", autofocus=""),
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment