Skip to content

JSONField loses styling if custom help_text is passed #19021

@jeremystretch

Description

@jeremystretch

Deployment Type

Self-hosted

NetBox Version

v4.2.6

Python Version

3.10

Steps to Reproduce

  1. Open the form to create a custom field
  2. Select "object" for the type of field
  3. Enter something in the "related object filter field"

Expected Behavior

The form field should use a monospace text to preserve formatting.

Observed Behavior

The form field uses regular text. This is due to a bug in the field's init method, which applies the font-monospace CSS class only if the default help_text is used:

def __init__(self, *args, **kwargs):
super().__init__(*args, **kwargs)
if not self.help_text:
self.help_text = _('Enter context data in <a href="https://json.org/">JSON</a> format.')
self.widget.attrs['placeholder'] = ''
self.widget.attrs['class'] = 'font-monospace'

Metadata

Metadata

Assignees

Labels

severity: lowDoes not significantly disrupt application functionality, or a workaround is availablestatus: acceptedThis issue has been accepted for implementationtype: bugA confirmed report of unexpected behavior in the application

Type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions