1
0
mirror of https://github.com/netbox-community/netbox.git synced 2024-05-10 07:54:54 +00:00
Files
netbox-community-netbox/netbox/utilities/templates/form_helpers/render_field.html
Jeremy Stretch 239d21870b Closes #14871: Complete work on UI cleanup (#15341)
* Fix left padding of login button in top menu

* Relocate "add" buttons for embedded object tables

* Remove unused data template block & getNetboxData() utility function

* Remove bottom margin from last <p> element in rendered Markdown inside a table cell

* Prevent TomSelect from initializing on <select> elements with a size

* Fix styling of dropdown menu button for circuit commit rate

* Change .color-block to display: inline-block

* Delete unused static asset

* Improve contrast between menu group headings & items

* Remove custom color for attr-table row headings

* Fix border color of copy-to-clipboard button

* Fix toast text color in dark mode

* Fix rack elevation label/image toggles

* Increase border radius for small buttons

* Fix object selector
2024-03-04 15:55:01 -05:00

75 lines
2.7 KiB
HTML

{% load form_helpers %}
{% load helpers %}
{% load i18n %}
<div class="row mb-3{% if field.errors %} has-errors{% endif %}">
{# Render the field label (if any), except for checkboxes #}
{% if label and not field|widget_type == 'checkboxinput' %}
<label for="{{ field.id_for_label }}" class="col-sm-3 col-form-label text-lg-end{% if field.field.required %} required{% endif %}">
{{ label }}
</label>
{% endif %}
{# Render the field itself #}
<div class="col{% if field|widget_type == 'checkboxinput' %} offset-3{% endif %}">
{# Include the "regenerate" button on slug fields #}
{% if field|widget_type == 'slugwidget' %}
<div class="input-group">
{{ field }}
<button id="reslug" type="button" title="{% trans "Regenerate Slug" %}" class="btn">
<i class="mdi mdi-reload"></i>
</button>
</div>
{# Render checkbox labels to the right of the field #}
{% elif field|widget_type == 'checkboxinput' %}
<div class="form-check mb-0">
{{ field }}
<label for="{{ field.id_for_label }}" class="form-check-label">
{{ label }}
</label>
{% if field.help_text %}
<span class="form-text">{{ field.help_text|safe }}</span>
{% endif %}
</div>
{# Include a copy-to-clipboard button #}
{% elif 'data-clipboard' in field.field.widget.attrs %}
<div class="input-group">
{{ field }}
<button type="button" title="{% trans "Copy to clipboard" %}" class="btn copy-content" data-clipboard-target="#{{ field.id_for_label }}">
<i class="mdi mdi-content-copy"></i>
</button>
</div>
{# Default field rendering #}
{% else %}
{{ field }}
{% endif %}
{# Display any error messages #}
{% if field.errors %}
<div class="form-text text-danger">
{% for error in field.errors %}{{ error }}{% if not forloop.last %}<br />{% endif %}{% endfor %}
</div>
{% elif field.field.required %}
<div class="invalid-feedback">
{% trans "This field is required" %}.
</div>
{% endif %}
{# Help text #}
{% if field.help_text and field|widget_type != 'checkboxinput' %}
<span class="form-text">{{ field.help_text|safe }}</span>
{% endif %}
{# For bulk edit forms, include an option to nullify the field #}
{% if bulk_nullable %}
<div class="form-check my-1">
<input type="checkbox" class="form-check-input" name="_nullify" value="{{ field.name }}" id="nullify_{{ field.id_for_label }}" />
<label for="nullify_{{ field.id_for_label }}" class="form-check-label">{% trans "Set Null" %}</label>
</div>
{% endif %}
</div>
</div>