Hide unused custom fields #1261

Closed
opened 2025-12-29 16:30:53 +01:00 by adam · 2 comments
Owner

Originally created by @Bill-Irvine on GitHub (Sep 25, 2017).

Issue type

[-] Feature request
[ ] Bug report
[ ] Documentation

Environment

  • Python version: 2.7
  • NetBox version: 2.1.4

Description

We have around 20 different types of circuits being stored in our database each with differing fields that require being filled out, i.e Dark Fibre links have completely separate details and fields to a Lit fibre circuit.

This leaves a large amount of blank space on the view of a completed circuit when accounting for the various types of circuits and their own custom fields.

One way of approaching this would be to allow separate custom fields per circuit type, but that seems like a much larger change that would require far more complexity, planning and modification.

The other much simpler option would be to have all fields accessible at circuit creation (and editing) and simply hide the ones that aren't in use.

Let me know your thoughts.

Originally created by @Bill-Irvine on GitHub (Sep 25, 2017). <!-- Before opening a new issue, please search through the existing issues to see if your topic has already been addressed. Note that you may need to remove the "is:open" filter from the search bar to include closed issues. Check the appropriate type for your issue below by placing an x between the brackets. If none of the below apply, please raise your issue for discussion on our mailing list: https://groups.google.com/forum/#!forum/netbox-discuss Please note that issues which do not fall under any of the below categories will be closed. ---> ### Issue type [-] Feature request <!-- Requesting the implementation of a new feature --> [ ] Bug report <!-- Reporting unexpected or erroneous behavior --> [ ] Documentation <!-- Proposing a modification to the documentation --> <!-- Please describe the environment in which you are running NetBox. (Be sure to verify that you are running the latest stable release of NetBox before submitting a bug report.) --> ### Environment * Python version: 2.7 * NetBox version: 2.1.4 <!-- BUG REPORTS must include: * A list of the steps needed to reproduce the bug * A description of the expected behavior * Any relevant error messages (screenshots may also help) FEATURE REQUESTS must include: * A detailed description of the proposed functionality * A use case for the new feature * A rough description of any necessary changes to the database schema * Any relevant third-party libraries which would be needed --> ### Description We have around 20 different types of circuits being stored in our database each with differing fields that require being filled out, i.e Dark Fibre links have completely separate details and fields to a Lit fibre circuit. This leaves a large amount of blank space on the view of a completed circuit when accounting for the various types of circuits and their own custom fields. One way of approaching this would be to allow separate custom fields per circuit type, but that seems like a much larger change that would require far more complexity, planning and modification. The other much simpler option would be to have all fields accessible at circuit creation (and editing) and simply hide the ones that aren't in use. Let me know your thoughts.
adam closed this issue 2025-12-29 16:30:53 +01:00
Author
Owner

@jeremystretch commented on GitHub (Sep 25, 2017):

Custom fields are meant to offer a minor convenience in tracking small amounts of esoteric data. If you've got twenty custom fields defined for a single type of object, I'd argue that you're better off using a separate application to store this data. Custom fields are already quite complex, and their abstract nature would exponentially increase that complexity if we tried to add the ability to limit the display of fields based on other object fields. Sorry, but I have to reject this if only for the sake of my own sanity.

@jeremystretch commented on GitHub (Sep 25, 2017): Custom fields are meant to offer a minor convenience in tracking small amounts of esoteric data. If you've got twenty custom fields defined for a single type of object, I'd argue that you're better off using a separate application to store this data. Custom fields are already quite complex, and their abstract nature would exponentially increase that complexity if we tried to add the ability to limit the display of fields based on other object fields. Sorry, but I have to reject this if only for the sake of my own sanity.
Author
Owner

@Bill-Irvine commented on GitHub (Sep 27, 2017):

Completely understand Jeremy, i know custom fields are a touchy subject :)

Just a note as i'm unsure if i got across what i intended. The idea was to simply change the html template of the custom fields panel to not display a custom field if its empty, not tie this to any particular circuit type.

The below works for me and is what i'm currently using if anybody else is interested.

custom_fields_panel.html

{% for field, value in custom_fields.items %}
	**{% if value is not None  %}**
                <tr>
                    <td>{{ field }}</td>
                    <td>
                        {% if field.type == 300 and value == True %}
                            <i class="glyphicon glyphicon-ok text-success" title="True"></i>
                        {% elif field.type == 300 and value == False %}
                            <i class="glyphicon glyphicon-remove text-danger" title="False"></i>
                        {% elif field.type == 500 and value %}
                            <a href="{{ value }}">{{ value|truncatechars:70 }}</a>
                        {% elif field.type == 200 or value %}
                            {{ value }}
                        {% elif field.required %}
                            <span class="text-warning">Not defined</span>
                        {% else %}
                            <span class="text-muted">N/A</span>
                        {% endif %}
                    </td>
                </tr>
	**{% endif %}**
{% endfor %}
@Bill-Irvine commented on GitHub (Sep 27, 2017): Completely understand Jeremy, i know custom fields are a touchy subject :) Just a note as i'm unsure if i got across what i intended. The idea was to simply change the html template of the custom fields panel to not display a custom field if its empty, not tie this to any particular circuit type. The below works for me and is what i'm currently using if anybody else is interested. custom_fields_panel.html ``` {% for field, value in custom_fields.items %} **{% if value is not None %}** <tr> <td>{{ field }}</td> <td> {% if field.type == 300 and value == True %} <i class="glyphicon glyphicon-ok text-success" title="True"></i> {% elif field.type == 300 and value == False %} <i class="glyphicon glyphicon-remove text-danger" title="False"></i> {% elif field.type == 500 and value %} <a href="{{ value }}">{{ value|truncatechars:70 }}</a> {% elif field.type == 200 or value %} {{ value }} {% elif field.required %} <span class="text-warning">Not defined</span> {% else %} <span class="text-muted">N/A</span> {% endif %} </td> </tr> **{% endif %}** {% endfor %} ```
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/netbox#1261