Skip to content

Commit

Permalink
Fix AppendedText label class (django-crispy-forms#184)
Browse files Browse the repository at this point in the history
  • Loading branch information
Yurii Zolotko committed Aug 19, 2024
1 parent 235c641 commit 5347aa2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<div id="div_{{ field.auto_id }}" class="mb-3{% if wrapper_class %} {{ wrapper_class }}{% endif %}{% if 'form-horizontal' in form_class %} row{% endif %}{% if form_group_wrapper_class %} {{ form_group_wrapper_class }}{% endif %}{% if form_show_errors and field.errors %} has-danger{% endif %}{% if field.css_classes %} {{ field.css_classes }}{% endif %}">

{% if field.label and form_show_labels %}
<label for="{{ field.id_for_label }}" class="{% if 'form-horizontal' in form_class %}col-form-label {% else %}form-label{% endif %}{{ label_class }}{% if field.field.required %} requiredField{% endif %}">
<label for="{{ field.id_for_label }}" class="{% if 'form-horizontal' in form_class %}col-form-label{% else %}form-label{% endif %} {{ label_class }}{% if field.field.required %} requiredField{% endif %}">
{{ field.label }}{% if field.field.required %}<span class="asteriskField">*</span>{% endif %}
</label>
{% endif %}
Expand Down
8 changes: 4 additions & 4 deletions tests/results/test_prepended_appended_text.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form method="post">
<div class="mb-3" id="div_id_email"><label class="form-label requiredField" for="id_email">email<span
<div class="mb-3" id="div_id_email"><label class="my-label form-label requiredField" for="id_email">email<span
class="asteriskField">*</span></label>
<div>
<div class="input-group"><span class="input-group-text">@&lt;&gt;&amp;</span><input aria-describedby="id_email_helptext"
Expand All @@ -8,19 +8,19 @@
class="form-text" id="id_email_helptext">Insert your email</div>
</div>
</div>
<div class="mb-3" id="div_id_password1"><label class="form-label requiredField" for="id_password1">password<span
<div class="mb-3" id="div_id_password1"><label class="my-label form-label requiredField" for="id_password1">password<span
class="asteriskField">*</span></label>
<div>
<div class="input-group"><input class="form-control textInput textinput" id="id_password1" maxlength="30"
name="password1" required type="password"><span class="input-group-text">#</span></div>
</div>
</div>
<div class="mb-3" id="div_id_password2"><label class="form-label requiredField" for="id_password2">re-enter
<div class="mb-3" id="div_id_password2"><label class="my-label form-label requiredField" for="id_password2">re-enter
password<span class="asteriskField">*</span></label>
<div >
<div class="input-group"><span class="input-group-text">$</span><input
class="form-control textInput textinput" id="id_password2" maxlength="30" name="password2" required
type="password"></div>
</div>
</div>
</form>
</form>
8 changes: 4 additions & 4 deletions tests/results/test_prepended_appended_text_lt50.html
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<form method="post">
<div class="mb-3" id="div_id_email"><label class="form-label requiredField" for="id_email">email<span
<div class="mb-3" id="div_id_email"><label class="my-label form-label requiredField" for="id_email">email<span
class="asteriskField">*</span></label>
<div>
<div class="input-group"><span class="input-group-text">@&lt;&gt;&amp;</span><input
Expand All @@ -8,19 +8,19 @@
class="form-text" id="id_email_helptext">Insert your email</div>
</div>
</div>
<div class="mb-3" id="div_id_password1"><label class="form-label requiredField" for="id_password1">password<span
<div class="mb-3" id="div_id_password1"><label class="my-label form-label requiredField" for="id_password1">password<span
class="asteriskField">*</span></label>
<div>
<div class="input-group"><input class="form-control textInput textinput" id="id_password1" maxlength="30"
name="password1" required type="password"><span class="input-group-text">#</span></div>
</div>
</div>
<div class="mb-3" id="div_id_password2"><label class="form-label requiredField" for="id_password2">re-enter
<div class="mb-3" id="div_id_password2"><label class="my-label form-label requiredField" for="id_password2">re-enter
password<span class="asteriskField">*</span></label>
<div >
<div class="input-group"><span class="input-group-text">$</span><input
class="form-control textInput textinput" id="id_password2" maxlength="30" name="password2" required
type="password"></div>
</div>
</div>
</form>
</form>
1 change: 1 addition & 0 deletions tests/test_layout_objects.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ def test_custom_django_widget(self):
def test_prepended_appended_text(self):
test_form = SampleForm()
test_form.helper = FormHelper()
test_form.helper.label_class = "my-label"
test_form.helper.layout = Layout(
PrependedAppendedText(
"email", "@<>&", "gmail.com", css_class="form-control-lg"
Expand Down

0 comments on commit 5347aa2

Please sign in to comment.