Skip to content

Commit

Permalink
Allow HTML in help text in form fields
Browse files Browse the repository at this point in the history
  • Loading branch information
Ash-Crow committed Nov 13, 2024
1 parent bee2749 commit b37b1b2
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions dsfr/templates/dsfr/form_field_snippets/input_snippet.html
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,12 @@
{# Generic input snippet used by most of the field types #}
<div class="{{ field.field.widget.group_class|default:'fr-input-group' }}{% if field.errors %} {{ field.field.widget.group_class|default:'fr-input-group' }}--error{% endif %}{% if field.field.disabled %} fr-input-group--disabled{% endif %}">
<label for="{{ field.id_for_label }}" class="fr-label">
{# djlint:off #}
{{ field.label }}{% if field.field.required %}*{% endif %}
{% if field.help_text %}
<span class="fr-hint-text">{{ field.help_text }}</span>
<span class="fr-hint-text">{{ field.help_text|safe }}</span>
{% endif %}
{# djlint:on #}
</label>
{% if field.errors %}
{% with aria_describedby="aria-describedby:"|add:field.auto_id|add:"-desc-error" %}
Expand All @@ -19,4 +21,4 @@
{{ field.errors }}
</div>
{% endif %}
</div>
</div>
2 changes: 1 addition & 1 deletion example_app/forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class ExampleForm(DsfrBaseForm):

user_email = forms.EmailField(
label="Adresse électronique",
help_text="Format attendu : [email protected]",
help_text="Format attendu : <code>[email protected]</code>",
required=False,
)

Expand Down

0 comments on commit b37b1b2

Please sign in to comment.