-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Regression from APISelect option optimization #3831
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
Comments
This seems to be related to the null option not being present, or rather no options being present at all. Firstly, if you make the following change, the VRF field and most others start working: --- a/netbox/utilities/templates/widgets/select_api.html
+++ b/netbox/utilities/templates/widgets/select_api.html
@@ -1,5 +1,5 @@
<select name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% for group_name, group_choices, group_index in widget.opt
- <optgroup label="{{ group_name }}">{% endif %}{% for widget in group_choices %}{% if widget.attrs.selected %}
+ <optgroup label="{{ group_name }}">{% endif %}{% for widget in group_choices %}{% if widget.attrs.selected or widget.value == "null" %}
{% include widget.template_name %}{% endif %}{% endfor %}{% if group_name %}
</optgroup>{% endif %}{% endfor %}
</select> However, there is still at least one field that I found not working: the I'm not 100% sure, but I think any static options (API will not return) will need to be put into the page (not filtered by the template). If it is just the null option that is always the exception, then the above diff will fix it, but if there instances where we mix multiple static options with an APISelect-based field, the patch won't work. But again, the patch above still doesn't fix the |
I think I found out why rack groups wasn't working: the default option has no value, so this fixes it --- a/netbox/utilities/templates/widgets/select_api.html
+++ b/netbox/utilities/templates/widgets/select_api.html
@@ -1,5 +1,5 @@
<select name="{{ widget.name }}"{% include "django/forms/widgets/attrs.html" %}>{% for group_name, group_choices, group_index in widget.optgroups %}{% if group_name %}
- <optgroup label="{{ group_name }}">{% endif %}{% for widget in group_choices %}{% if widget.attrs.selected %}
+ <optgroup label="{{ group_name }}">{% endif %}{% for widget in group_choices %}{% if widget.attrs.selected or widget.value == "null" or not widget.value %}
{% include widget.template_name %}{% endif %}{% endfor %}{% if group_name %}
</optgroup>{% endif %}{% endfor %}
</select> I don't know if this is the best or most efficient solution considering I'm accounting for two exception manually |
This is also happening on the |
Going to stick with |
@jeremystretch thanks for fixing and sorry for the mess. |
@hSaria No worries, I didn't catch it either. |
Environment
Steps to Reproduce
/ipam/ip-addresses/
)There are multiple places that this is happening at. This is one example.
Following #3812, it seems I messed up some APISelect-based fields and I'm still unsure what's affected and what's not (I'll put a comment with more info).
Expected Behavior
The list of VRFs is shown
Observed Behavior
Select is stuck at
Searching...
The text was updated successfully, but these errors were encountered: