You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import string
import json
from django.contrib.contenttypes.models import ContentType
from dcim.choices import DeviceFaceChoices, DeviceStatusChoices, CableTypeChoices, InterfaceTypeChoices
from dcim.models import Cable, Device, DeviceRole, DeviceType, FrontPort, Interface, Manufacturer, Site, Platform, PowerPort, PowerOutlet, Rack
from ipam.models import VLAN
from extras.scripts import *
from django.conf import settings
from tenancy.models import Tenant
from django import forms
from utilities.forms.fields import *
from utilities.forms.widgets import APISelect, APISelectMultiple, HTMXSelect
class NewMacVrf(Script):
class Meta:
name = "New mac-vrf"
description = "Add a mac-vrf"
#field_order = ['macvrf_id', 'description', 'interfaces', 'vlan']
### others objects removed
interfaces_multi= MultiObjectVar(
description="Interfaces",
model=Interface,
widget=APISelectMultiple(
api_url='/api/dcim/interfaces/',
attrs={'selector' : 'dcim.interface'},
)
)
def run(self, data, commit):
output = []
for key, value in data.items():
output.append(f"{key}: {value}")
return '\n'.join(output)
The selector works, but if something is selected from the selector its not get append the to the MultiObjectVar, if I use APISelect instead, the interface gets appended, but obviously its than a single object.
Expected Behavior
Actually I would expect that MultiObjectVar is supporting the selector natively, instead using the widget as "workaround"
But I would as expect that it works with the APISelectMultiple widget.
Observed Behavior
The selector works, but if something is selected from the selector its not get append the to the MultiObjectVar, if I use APISelect instead, the interface gets appended, but obviously its than a single object.
The text was updated successfully, but these errors were encountered:
Thank you for your report, however I'm afraid I don't see how this can be classified as a bug. The selector hasn't been implemented for multiple choice fields and core netbox doesn't use it for multiple choice fields yet. I guess it could be raised as a FR instead to add native support for the selector argument to both MultiObjectVar and ObjectVar, so feel free to do that.
There's also an issue somewhere, but I can't find it, where @jeremystretch mentioned that the object selector hasn't been implemented for multiple choice fields yet. Might be worth looking for as a way to get this implemented.
NetBox version
v3.5.5
Python version
3.10
Steps to Reproduce
Create a custom script like this:
The selector works, but if something is selected from the selector its not get append the to the MultiObjectVar, if I use APISelect instead, the interface gets appended, but obviously its than a single object.
Expected Behavior
Actually I would expect that MultiObjectVar is supporting the selector natively, instead using the widget as "workaround"
But I would as expect that it works with the APISelectMultiple widget.
Observed Behavior
The selector works, but if something is selected from the selector its not get append the to the MultiObjectVar, if I use APISelect instead, the interface gets appended, but obviously its than a single object.
The text was updated successfully, but these errors were encountered: