Created
November 17, 2017 12:12
-
-
Save yunti/8c091cd446082eb1208e076594fc2439 to your computer and use it in GitHub Desktop.
crispy form no error with bootstrap beta
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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