Skip to content

Fixes #19415: Increased Circuit/WirelessLink distance upper limit #19495

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

Merged
merged 8 commits into from
May 19, 2025
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Clean up new has_field_errors mechanism, fix issue with ObjectAttribute
  • Loading branch information
jnovinger committed May 16, 2025
commit cb82810b2741e287e40e11e134da1d5c6164f659
4 changes: 2 additions & 2 deletions netbox/utilities/templates/form_helpers/render_fieldset.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<h2 class="col-9 offset-3">{{ heading }}</h2>
</div>
{% endif %}
{% for layout, title, items, has_errors in rows %}
{% for layout, title, items, has_field_errors in rows %}

{% if layout == 'field' %}
{# Single form field #}
Expand All @@ -25,7 +25,7 @@ <h2 class="col-9 offset-3">{{ heading }}</h2>

{% elif layout == 'inline' %}
{# Multiple form fields on the same line #}
<div class="row mb-3 {% if has_errors %} has-errors{% endif %}">
<div class="row mb-3 {% if has_field_errors %} has-errors{% endif %}">
<label class="col col-3 col-form-label text-lg-end">{{ title|default:'' }}</label>
{% for field in items %}
<div class="col mb-1 {% if field.errors %} has-errors{% endif %}">
Expand Down
11 changes: 8 additions & 3 deletions netbox/utilities/templatetags/form_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ def widget_type(field):
def render_fieldset(form, fieldset):
"""
Render a group set of fields.

The signature for row tuples is (layout, title, items, has_field_errors).
"""
rows = []

Expand All @@ -75,18 +77,21 @@ def render_fieldset(form, fieldset):
'fields': [form[name] for name in tab['fields'] if name in form.fields]
} for tab in item.tabs
]
has_field_errors = any(
field.errors for tab in tabs for field in tab['fields']
)
# If none of the tabs has been marked as active, activate the first one
if not any(tab['active'] for tab in tabs):
tabs[0]['active'] = True
rows.append(
('tabs', None, tabs, False)
('tabs', None, tabs, has_field_errors)
)

elif type(item) is ObjectAttribute:
value = getattr(form.instance, item.name)
label = value._meta.verbose_name if hasattr(value, '_meta') else item.name
rows.append(
('attribute', label.title(), [value])
('attribute', label.title(), [value], False)
)

# A single form field
Expand All @@ -96,7 +101,7 @@ def render_fieldset(form, fieldset):
if field.name in getattr(form, 'nullable_fields', []):
field._nullable = True
rows.append(
('field', None, [field], False)
('field', None, [field], bool(field.errors))
)

return {
Expand Down