Skip to content

Commit 6e4b4a5

Browse files
12685 use markdown for custom fields added to form (#13828)
* 12685 use markdown for custom fields added to form * 13809 change markdown to use utilities * Add help_text for CustomField description indicating Markdown support --------- Co-authored-by: Jeremy Stretch <[email protected]>
1 parent 7a410df commit 6e4b4a5

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

netbox/extras/forms/model_forms.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ class Meta:
7676
'type': _(
7777
"The type of data stored in this field. For object/multi-object fields, select the related object "
7878
"type below."
79-
)
79+
),
80+
'description': _("This will be displayed as help text for the form field. Markdown is supported.")
8081
}
8182

8283
def __init__(self, *args, **kwargs):

netbox/extras/models/customfields.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
from utilities.forms.utils import add_blank_choice
2929
from utilities.forms.widgets import APISelect, APISelectMultiple, DatePicker, DateTimePicker
3030
from utilities.querysets import RestrictedQuerySet
31+
from utilities.templatetags.builtins.filters import render_markdown
3132
from utilities.validators import validate_regex
3233

3334
__all__ = (
@@ -498,7 +499,7 @@ def to_form_field(self, set_initial=True, enforce_required=True, enforce_visibil
498499
field.model = self
499500
field.label = str(self)
500501
if self.description:
501-
field.help_text = escape(self.description)
502+
field.help_text = render_markdown(self.description)
502503

503504
# Annotate read-only fields
504505
if enforce_visibility and self.ui_visibility == CustomFieldVisibilityChoices.VISIBILITY_READ_ONLY:

0 commit comments

Comments
 (0)