From d2193303d84131bff91ceab71e2be506c054d7ca Mon Sep 17 00:00:00 2001 From: Nik Nyby Date: Wed, 4 Mar 2015 13:34:28 -0500 Subject: [PATCH] Use field.id_for_label instead of field.auto_id This fixes a bug when specifying a custom id for a field and rendering it with the `|bootstrap` filter. When using `field.auto_id` in the label's `for` attribute, this is always set to the default value instead of the custom `id`. Also fix a typo in the tests: file_fied -> file_field --- bootstrapform/fixtures/basic.html | 6 +++--- bootstrapform/fixtures/horizontal.html | 6 +++--- bootstrapform/templates/bootstrapform/field.html | 3 ++- bootstrapform/tests.py | 2 +- example/app/forms.py | 2 +- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/bootstrapform/fixtures/basic.html b/bootstrapform/fixtures/basic.html index d316ca5..81caa6f 100644 --- a/bootstrapform/fixtures/basic.html +++ b/bootstrapform/fixtures/basic.html @@ -54,7 +54,7 @@
- +
  • @@ -65,10 +65,10 @@
- +
- +
diff --git a/bootstrapform/fixtures/horizontal.html b/bootstrapform/fixtures/horizontal.html index 5634218..d9b1e43 100644 --- a/bootstrapform/fixtures/horizontal.html +++ b/bootstrapform/fixtures/horizontal.html @@ -56,7 +56,7 @@
- +
  • @@ -67,10 +67,10 @@
- +
- +
diff --git a/bootstrapform/templates/bootstrapform/field.html b/bootstrapform/templates/bootstrapform/field.html index bfbdf64..ef5b614 100644 --- a/bootstrapform/templates/bootstrapform/field.html +++ b/bootstrapform/templates/bootstrapform/field.html @@ -46,7 +46,8 @@
{% else %} {% if field.auto_id %} - + {% endif %}
diff --git a/bootstrapform/tests.py b/bootstrapform/tests.py index 5b90058..181c63b 100644 --- a/bootstrapform/tests.py +++ b/bootstrapform/tests.py @@ -28,7 +28,7 @@ class ExampleForm(forms.Form): radio_choice = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect) multiple_choice = forms.MultipleChoiceField(choices=CHOICES) multiple_checkbox = forms.MultipleChoiceField(choices=CHOICES, widget=forms.CheckboxSelectMultiple) - file_fied = forms.FileField() + file_field = forms.FileField() password_field = forms.CharField(widget=forms.PasswordInput) textarea = forms.CharField(widget=forms.Textarea) boolean_field = forms.BooleanField() diff --git a/example/app/forms.py b/example/app/forms.py index 6e4409d..72324d4 100644 --- a/example/app/forms.py +++ b/example/app/forms.py @@ -12,7 +12,7 @@ class ExampleForm(forms.Form): radio_choice = forms.ChoiceField(choices=CHOICES, widget=forms.RadioSelect) multiple_choice = forms.MultipleChoiceField(choices=CHOICES) multiple_checkbox = forms.MultipleChoiceField(choices=CHOICES, widget=forms.CheckboxSelectMultiple) - file_fied = forms.FileField() + file_field = forms.FileField() password_field = forms.CharField(widget=forms.PasswordInput) textarea = forms.CharField(widget=forms.Textarea) boolean_field = forms.BooleanField()