Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use field.id_for_label instead of field.auto_id #66

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bootstrapform/fixtures/basic.html
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
</div>

<div class="form-group">
<label class="control-label " for="id_multiple_checkbox">Multiple checkbox</label>
<label class="control-label " for="id_multiple_checkbox_0">Multiple checkbox</label>
<div class=" multiple-checkbox">
<ul id="id_multiple_checkbox">
<li><label for="id_multiple_checkbox_0"><input id="id_multiple_checkbox_0" name="multiple_checkbox" type="checkbox" value="0" /> Zero</label></li>
Expand All @@ -65,10 +65,10 @@
</div>

<div class="form-group">
<label class="control-label " for="id_file_fied">File fied</label>
<label class="control-label " for="id_file_field">File field</label>

<div class=" ">
<input id="id_file_fied" name="file_fied" type="file" />
<input id="id_file_field" name="file_field" type="file" />
</div>
</div>

Expand Down
6 changes: 3 additions & 3 deletions bootstrapform/fixtures/horizontal.html
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@
</div>

<div class="form-group">
<label class="control-label col-sm-2 col-lg-2 " for="id_multiple_checkbox">Multiple checkbox</label>
<label class="control-label col-sm-2 col-lg-2 " for="id_multiple_checkbox_0">Multiple checkbox</label>
<div class=" col-sm-10 col-lg-10 multiple-checkbox">
<ul id="id_multiple_checkbox">
<li><label for="id_multiple_checkbox_0"><input id="id_multiple_checkbox_0" name="multiple_checkbox" type="checkbox" value="0" /> Zero</label></li>
Expand All @@ -67,10 +67,10 @@
</div>

<div class="form-group">
<label class="control-label col-sm-2 col-lg-2 " for="id_file_fied">File fied</label>
<label class="control-label col-sm-2 col-lg-2 " for="id_file_field">File field</label>

<div class=" col-sm-10 col-lg-10 ">
<input id="id_file_fied" name="file_fied" type="file" />
<input id="id_file_field" name="file_field" type="file" />
</div>
</div>

Expand Down
3 changes: 2 additions & 1 deletion bootstrapform/templates/bootstrapform/field.html
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@
</div>
{% else %}
{% if field.auto_id %}
<label class="control-label {{ classes.label }} {% if field.field.required %}{{ form.required_css_class }}{% endif %}" for="{{ field.auto_id }}">{{ field.label }}</label>
<label class="control-label {{ classes.label }} {% if field.field.required %}{{ form.required_css_class }}{% endif %}"
for="{{ field.id_for_label }}">{{ field.label }}</label>
{% endif %}

<div class="{{ classes.value }} {% if field|is_multiple_checkbox %}multiple-checkbox{% endif %}">
Expand Down
2 changes: 1 addition & 1 deletion bootstrapform/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion example/app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()