I have a one field form which I want to align horizontally and centre of page.
I want to have autofocus and placeholder enabled.
Here is my code:
class VinForm(forms.Form):
VIN = forms.CharField(max_length=17, label='VIN')
def __init__(self, *args, **kwargs):
super(VinForm, self).__init__(*args, **kwargs)
self.helper = FormHelper()
self.helper.form_method = 'post'
#self.helper.form_class = 'form-horizontal col-xs-12 col-md-6 col-lg-5'
self.helper.form_class = 'form-horizontal'
#self.helper.form_class = 'form-inline col-md-12'
#self.helper.label_class = 'col-xs-3 col-md-3 col-lg-3'
#self.helper.field_class = 'col-xs-12 col-md-12 col-lg-12'
#self.helper.form_class = 'form-inline'
self. helper.layout = Layout(
FieldWithButtons('VIN', StrictButton("Go!"), autofocus=True, placeholder='JN1HJ01F8RT231164'),
# Div(
# Div('VIN',css_class='col-md-6',autofocus=True, placeholder='JN1HJ01F8RT231164'),
# css_class='row',
# ),
# Fieldset(
# #'Get Driving profile',
# Field('VIN', autofocus=True, placeholder='JN1HJ01F8RT231164'),
# ),
# FormActions(
# Submit('submit', 'get vehicle info'),
# ),
# )
)
you can see from my code above that I tried many things still none worked. Here is how it looks.
It lacks
1) center of page
2) inline form
3) autofocus and placeholders are not working
I am using twitter bootstrap3
The crispy forms documentation shows how to do horizontal forms for bootstrap, perhaps that will help. http://django-crispy-forms.readthedocs.org/en/latest/crispy_tag_forms.html?highlight=horizontal#bootstrap3-horizontal-forms