We are currently solving the following issue within our repository. Here is the issue text:
--- BEGIN ISSUE ---
Circuit termination on interface not working when accesssed from interface table
### NetBox version

v3.3-beta1

### Python version

3.9

### Steps to Reproduce

1. Create device with interfaces
2. Create circuit with Z-side on same site as device
3. Try to connect interface to circuit termination from interface table
4. Select B Side Cicuit
5. Try to select Side for circuit

### Expected Behavior

On B Side you are able to select side for circuit

### Observed Behavior

Side option menu is empty because.

This is caused because $ is missing for `$termination_{cable_end}_circuit`

https://github.com/netbox-community/netbox/blob/abfa6a325af17d65038304feed2536330d8c60a7/netbox/dcim/forms/connections.py#L141
Circuit termination on interface not working when accesssed from interface table
### NetBox version

v3.3-beta1

### Python version

3.9

### Steps to Reproduce

1. Create device with interfaces
2. Create circuit with Z-side on same site as device
3. Try to connect interface to circuit termination from interface table
4. Select B Side Cicuit
5. Try to select Side for circuit

### Expected Behavior

On B Side you are able to select side for circuit

### Observed Behavior

Side option menu is empty because.

This is caused because $ is missing for `$termination_{cable_end}_circuit`

https://github.com/netbox-community/netbox/blob/abfa6a325af17d65038304feed2536330d8c60a7/netbox/dcim/forms/connections.py#L141

--- END ISSUE ---

Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
--- BEGIN FILES ---
Path: `netbox/dcim/forms/connections.py`
Content:
```
1 from django import forms
2 
3 from circuits.models import Circuit, CircuitTermination, Provider
4 from dcim.models import *
5 from utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField
6 from .models import CableForm
7 
8 
9 def get_cable_form(a_type, b_type):
10 
11     class FormMetaclass(forms.models.ModelFormMetaclass):
12 
13         def __new__(mcs, name, bases, attrs):
14 
15             for cable_end, term_cls in (('a', a_type), ('b', b_type)):
16 
17                 attrs[f'termination_{cable_end}_region'] = DynamicModelChoiceField(
18                     queryset=Region.objects.all(),
19                     label='Region',
20                     required=False,
21                     initial_params={
22                         'sites': f'$termination_{cable_end}_site'
23                     }
24                 )
25                 attrs[f'termination_{cable_end}_sitegroup'] = DynamicModelChoiceField(
26                     queryset=SiteGroup.objects.all(),
27                     label='Site group',
28                     required=False,
29                     initial_params={
30                         'sites': f'$termination_{cable_end}_site'
31                     }
32                 )
33                 attrs[f'termination_{cable_end}_site'] = DynamicModelChoiceField(
34                     queryset=Site.objects.all(),
35                     label='Site',
36                     required=False,
37                     query_params={
38                         'region_id': f'$termination_{cable_end}_region',
39                         'group_id': f'$termination_{cable_end}_sitegroup',
40                     }
41                 )
42                 attrs[f'termination_{cable_end}_location'] = DynamicModelChoiceField(
43                     queryset=Location.objects.all(),
44                     label='Location',
45                     required=False,
46                     null_option='None',
47                     query_params={
48                         'site_id': f'$termination_{cable_end}_site'
49                     }
50                 )
51 
52                 # Device component
53                 if hasattr(term_cls, 'device'):
54 
55                     attrs[f'termination_{cable_end}_rack'] = DynamicModelChoiceField(
56                         queryset=Rack.objects.all(),
57                         label='Rack',
58                         required=False,
59                         null_option='None',
60                         initial_params={
61                             'devices': f'$termination_{cable_end}_device'
62                         },
63                         query_params={
64                             'site_id': f'$termination_{cable_end}_site',
65                             'location_id': f'$termination_{cable_end}_location',
66                         }
67                     )
68                     attrs[f'termination_{cable_end}_device'] = DynamicModelChoiceField(
69                         queryset=Device.objects.all(),
70                         label='Device',
71                         required=False,
72                         initial_params={
73                             f'{term_cls._meta.model_name}s__in': f'${cable_end}_terminations'
74                         },
75                         query_params={
76                             'site_id': f'$termination_{cable_end}_site',
77                             'location_id': f'$termination_{cable_end}_location',
78                             'rack_id': f'$termination_{cable_end}_rack',
79                         }
80                     )
81                     attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
82                         queryset=term_cls.objects.all(),
83                         label=term_cls._meta.verbose_name.title(),
84                         disabled_indicator='_occupied',
85                         query_params={
86                             'device_id': f'$termination_{cable_end}_device',
87                         }
88                     )
89 
90                 # PowerFeed
91                 elif term_cls == PowerFeed:
92 
93                     attrs[f'termination_{cable_end}_powerpanel'] = DynamicModelChoiceField(
94                         queryset=PowerPanel.objects.all(),
95                         label='Power Panel',
96                         required=False,
97                         initial_params={
98                             'powerfeeds__in': f'${cable_end}_terminations'
99                         },
100                         query_params={
101                             'site_id': f'$termination_{cable_end}_site',
102                             'location_id': f'$termination_{cable_end}_location',
103                         }
104                     )
105                     attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
106                         queryset=term_cls.objects.all(),
107                         label='Power Feed',
108                         disabled_indicator='_occupied',
109                         query_params={
110                             'powerpanel_id': f'$termination_{cable_end}_powerpanel',
111                         }
112                     )
113 
114                 # CircuitTermination
115                 elif term_cls == CircuitTermination:
116 
117                     attrs[f'termination_{cable_end}_provider'] = DynamicModelChoiceField(
118                         queryset=Provider.objects.all(),
119                         label='Provider',
120                         initial_params={
121                             'circuits': f'$termination_{cable_end}_circuit'
122                         },
123                         required=False
124                     )
125                     attrs[f'termination_{cable_end}_circuit'] = DynamicModelChoiceField(
126                         queryset=Circuit.objects.all(),
127                         label='Circuit',
128                         initial_params={
129                             'terminations__in': f'${cable_end}_terminations'
130                         },
131                         query_params={
132                             'provider_id': f'$termination_{cable_end}_provider',
133                             'site_id': f'$termination_{cable_end}_site',
134                         }
135                     )
136                     attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(
137                         queryset=term_cls.objects.all(),
138                         label='Side',
139                         disabled_indicator='_occupied',
140                         query_params={
141                             'circuit_id': f'termination_{cable_end}_circuit',
142                         }
143                     )
144 
145             return super().__new__(mcs, name, bases, attrs)
146 
147     class _CableForm(CableForm, metaclass=FormMetaclass):
148 
149         def __init__(self, *args, **kwargs):
150 
151             # TODO: Temporary hack to work around list handling limitations with utils.normalize_querydict()
152             for field_name in ('a_terminations', 'b_terminations'):
153                 if field_name in kwargs.get('initial', {}) and type(kwargs['initial'][field_name]) is not list:
154                     kwargs['initial'][field_name] = [kwargs['initial'][field_name]]
155 
156             super().__init__(*args, **kwargs)
157 
158             if self.instance and self.instance.pk:
159                 # Initialize A/B terminations when modifying an existing Cable instance
160                 self.initial['a_terminations'] = self.instance.a_terminations
161                 self.initial['b_terminations'] = self.instance.b_terminations
162 
163         def clean(self):
164             super().clean()
165 
166             # Set the A/B terminations on the Cable instance
167             self.instance.a_terminations = self.cleaned_data['a_terminations']
168             self.instance.b_terminations = self.cleaned_data['b_terminations']
169 
170     return _CableForm
171
```
--- END FILES ---

Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.

Here is an example:

```diff
diff --git a/examples/server_async.py b/examples/server_async.py
--- a/examples/server_async.py
+++ b/examples/server_async.py
@@ -313,4 +313,4 @@
 
 
 if __name__ == "__main__":
-    asyncio.run(run_async_server("."), debug=True)
+    asyncio.run(run_async_server(), debug=True)
diff --git a/examples/server_sync.py b/examples/server_sync.py
--- a/examples/server_sync.py
+++ b/examples/server_sync.py
@@ -313,5 +313,5 @@
 
 
 if __name__ == "__main__":
-    server = run_sync_server(".")
+    server = run_sync_server()
     server.shutdown()

```

diff --git a/netbox/dcim/forms/connections.py b/netbox/dcim/forms/connections.py
--- a/netbox/dcim/forms/connections.py
+++ b/netbox/dcim/forms/connections.py
@@ -138,7 +138,7 @@
                         label='Side',
                         disabled_indicator='_occupied',
                         query_params={
-                            'circuit_id': f'termination_{cable_end}_circuit',
+                            'circuit_id': f'$termination_{cable_end}_circuit',
                         }
                     )

{"golden_diff": "diff --git a/netbox/dcim/forms/connections.py b/netbox/dcim/forms/connections.py\n--- a/netbox/dcim/forms/connections.py\n+++ b/netbox/dcim/forms/connections.py\n@@ -138,7 +138,7 @@\n                         label='Side',\n                         disabled_indicator='_occupied',\n                         query_params={\n-                            'circuit_id': f'termination_{cable_end}_circuit',\n+                            'circuit_id': f'$termination_{cable_end}_circuit',\n                         }\n                     )\n", "issue": "Circuit termination on interface not working when accesssed from interface table\n### NetBox version\n\nv3.3-beta1\n\n### Python version\n\n3.9\n\n### Steps to Reproduce\n\n1. Create device with interfaces\r\n2. Create circuit with Z-side on same site as device\r\n3. Try to connect interface to circuit termination from interface table\r\n4. Select B Side Cicuit\r\n5. Try to select Side for circuit\n\n### Expected Behavior\n\nOn B Side you are able to select side for circuit\n\n### Observed Behavior\n\nSide option menu is empty because.\r\n\r\nThis is caused because $ is missing for `$termination_{cable_end}_circuit`\r\n\r\nhttps://github.com/netbox-community/netbox/blob/abfa6a325af17d65038304feed2536330d8c60a7/netbox/dcim/forms/connections.py#L141\nCircuit termination on interface not working when accesssed from interface table\n### NetBox version\n\nv3.3-beta1\n\n### Python version\n\n3.9\n\n### Steps to Reproduce\n\n1. Create device with interfaces\r\n2. Create circuit with Z-side on same site as device\r\n3. Try to connect interface to circuit termination from interface table\r\n4. Select B Side Cicuit\r\n5. Try to select Side for circuit\n\n### Expected Behavior\n\nOn B Side you are able to select side for circuit\n\n### Observed Behavior\n\nSide option menu is empty because.\r\n\r\nThis is caused because $ is missing for `$termination_{cable_end}_circuit`\r\n\r\nhttps://github.com/netbox-community/netbox/blob/abfa6a325af17d65038304feed2536330d8c60a7/netbox/dcim/forms/connections.py#L141\n", "before_files": [{"content": "from django import forms\n\nfrom circuits.models import Circuit, CircuitTermination, Provider\nfrom dcim.models import *\nfrom utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField\nfrom .models import CableForm\n\n\ndef get_cable_form(a_type, b_type):\n\n    class FormMetaclass(forms.models.ModelFormMetaclass):\n\n        def __new__(mcs, name, bases, attrs):\n\n            for cable_end, term_cls in (('a', a_type), ('b', b_type)):\n\n                attrs[f'termination_{cable_end}_region'] = DynamicModelChoiceField(\n                    queryset=Region.objects.all(),\n                    label='Region',\n                    required=False,\n                    initial_params={\n                        'sites': f'$termination_{cable_end}_site'\n                    }\n                )\n                attrs[f'termination_{cable_end}_sitegroup'] = DynamicModelChoiceField(\n                    queryset=SiteGroup.objects.all(),\n                    label='Site group',\n                    required=False,\n                    initial_params={\n                        'sites': f'$termination_{cable_end}_site'\n                    }\n                )\n                attrs[f'termination_{cable_end}_site'] = DynamicModelChoiceField(\n                    queryset=Site.objects.all(),\n                    label='Site',\n                    required=False,\n                    query_params={\n                        'region_id': f'$termination_{cable_end}_region',\n                        'group_id': f'$termination_{cable_end}_sitegroup',\n                    }\n                )\n                attrs[f'termination_{cable_end}_location'] = DynamicModelChoiceField(\n                    queryset=Location.objects.all(),\n                    label='Location',\n                    required=False,\n                    null_option='None',\n                    query_params={\n                        'site_id': f'$termination_{cable_end}_site'\n                    }\n                )\n\n                # Device component\n                if hasattr(term_cls, 'device'):\n\n                    attrs[f'termination_{cable_end}_rack'] = DynamicModelChoiceField(\n                        queryset=Rack.objects.all(),\n                        label='Rack',\n                        required=False,\n                        null_option='None',\n                        initial_params={\n                            'devices': f'$termination_{cable_end}_device'\n                        },\n                        query_params={\n                            'site_id': f'$termination_{cable_end}_site',\n                            'location_id': f'$termination_{cable_end}_location',\n                        }\n                    )\n                    attrs[f'termination_{cable_end}_device'] = DynamicModelChoiceField(\n                        queryset=Device.objects.all(),\n                        label='Device',\n                        required=False,\n                        initial_params={\n                            f'{term_cls._meta.model_name}s__in': f'${cable_end}_terminations'\n                        },\n                        query_params={\n                            'site_id': f'$termination_{cable_end}_site',\n                            'location_id': f'$termination_{cable_end}_location',\n                            'rack_id': f'$termination_{cable_end}_rack',\n                        }\n                    )\n                    attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(\n                        queryset=term_cls.objects.all(),\n                        label=term_cls._meta.verbose_name.title(),\n                        disabled_indicator='_occupied',\n                        query_params={\n                            'device_id': f'$termination_{cable_end}_device',\n                        }\n                    )\n\n                # PowerFeed\n                elif term_cls == PowerFeed:\n\n                    attrs[f'termination_{cable_end}_powerpanel'] = DynamicModelChoiceField(\n                        queryset=PowerPanel.objects.all(),\n                        label='Power Panel',\n                        required=False,\n                        initial_params={\n                            'powerfeeds__in': f'${cable_end}_terminations'\n                        },\n                        query_params={\n                            'site_id': f'$termination_{cable_end}_site',\n                            'location_id': f'$termination_{cable_end}_location',\n                        }\n                    )\n                    attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(\n                        queryset=term_cls.objects.all(),\n                        label='Power Feed',\n                        disabled_indicator='_occupied',\n                        query_params={\n                            'powerpanel_id': f'$termination_{cable_end}_powerpanel',\n                        }\n                    )\n\n                # CircuitTermination\n                elif term_cls == CircuitTermination:\n\n                    attrs[f'termination_{cable_end}_provider'] = DynamicModelChoiceField(\n                        queryset=Provider.objects.all(),\n                        label='Provider',\n                        initial_params={\n                            'circuits': f'$termination_{cable_end}_circuit'\n                        },\n                        required=False\n                    )\n                    attrs[f'termination_{cable_end}_circuit'] = DynamicModelChoiceField(\n                        queryset=Circuit.objects.all(),\n                        label='Circuit',\n                        initial_params={\n                            'terminations__in': f'${cable_end}_terminations'\n                        },\n                        query_params={\n                            'provider_id': f'$termination_{cable_end}_provider',\n                            'site_id': f'$termination_{cable_end}_site',\n                        }\n                    )\n                    attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(\n                        queryset=term_cls.objects.all(),\n                        label='Side',\n                        disabled_indicator='_occupied',\n                        query_params={\n                            'circuit_id': f'termination_{cable_end}_circuit',\n                        }\n                    )\n\n            return super().__new__(mcs, name, bases, attrs)\n\n    class _CableForm(CableForm, metaclass=FormMetaclass):\n\n        def __init__(self, *args, **kwargs):\n\n            # TODO: Temporary hack to work around list handling limitations with utils.normalize_querydict()\n            for field_name in ('a_terminations', 'b_terminations'):\n                if field_name in kwargs.get('initial', {}) and type(kwargs['initial'][field_name]) is not list:\n                    kwargs['initial'][field_name] = [kwargs['initial'][field_name]]\n\n            super().__init__(*args, **kwargs)\n\n            if self.instance and self.instance.pk:\n                # Initialize A/B terminations when modifying an existing Cable instance\n                self.initial['a_terminations'] = self.instance.a_terminations\n                self.initial['b_terminations'] = self.instance.b_terminations\n\n        def clean(self):\n            super().clean()\n\n            # Set the A/B terminations on the Cable instance\n            self.instance.a_terminations = self.cleaned_data['a_terminations']\n            self.instance.b_terminations = self.cleaned_data['b_terminations']\n\n    return _CableForm\n", "path": "netbox/dcim/forms/connections.py"}], "after_files": [{"content": "from django import forms\n\nfrom circuits.models import Circuit, CircuitTermination, Provider\nfrom dcim.models import *\nfrom utilities.forms import DynamicModelChoiceField, DynamicModelMultipleChoiceField\nfrom .models import CableForm\n\n\ndef get_cable_form(a_type, b_type):\n\n    class FormMetaclass(forms.models.ModelFormMetaclass):\n\n        def __new__(mcs, name, bases, attrs):\n\n            for cable_end, term_cls in (('a', a_type), ('b', b_type)):\n\n                attrs[f'termination_{cable_end}_region'] = DynamicModelChoiceField(\n                    queryset=Region.objects.all(),\n                    label='Region',\n                    required=False,\n                    initial_params={\n                        'sites': f'$termination_{cable_end}_site'\n                    }\n                )\n                attrs[f'termination_{cable_end}_sitegroup'] = DynamicModelChoiceField(\n                    queryset=SiteGroup.objects.all(),\n                    label='Site group',\n                    required=False,\n                    initial_params={\n                        'sites': f'$termination_{cable_end}_site'\n                    }\n                )\n                attrs[f'termination_{cable_end}_site'] = DynamicModelChoiceField(\n                    queryset=Site.objects.all(),\n                    label='Site',\n                    required=False,\n                    query_params={\n                        'region_id': f'$termination_{cable_end}_region',\n                        'group_id': f'$termination_{cable_end}_sitegroup',\n                    }\n                )\n                attrs[f'termination_{cable_end}_location'] = DynamicModelChoiceField(\n                    queryset=Location.objects.all(),\n                    label='Location',\n                    required=False,\n                    null_option='None',\n                    query_params={\n                        'site_id': f'$termination_{cable_end}_site'\n                    }\n                )\n\n                # Device component\n                if hasattr(term_cls, 'device'):\n\n                    attrs[f'termination_{cable_end}_rack'] = DynamicModelChoiceField(\n                        queryset=Rack.objects.all(),\n                        label='Rack',\n                        required=False,\n                        null_option='None',\n                        initial_params={\n                            'devices': f'$termination_{cable_end}_device'\n                        },\n                        query_params={\n                            'site_id': f'$termination_{cable_end}_site',\n                            'location_id': f'$termination_{cable_end}_location',\n                        }\n                    )\n                    attrs[f'termination_{cable_end}_device'] = DynamicModelChoiceField(\n                        queryset=Device.objects.all(),\n                        label='Device',\n                        required=False,\n                        initial_params={\n                            f'{term_cls._meta.model_name}s__in': f'${cable_end}_terminations'\n                        },\n                        query_params={\n                            'site_id': f'$termination_{cable_end}_site',\n                            'location_id': f'$termination_{cable_end}_location',\n                            'rack_id': f'$termination_{cable_end}_rack',\n                        }\n                    )\n                    attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(\n                        queryset=term_cls.objects.all(),\n                        label=term_cls._meta.verbose_name.title(),\n                        disabled_indicator='_occupied',\n                        query_params={\n                            'device_id': f'$termination_{cable_end}_device',\n                        }\n                    )\n\n                # PowerFeed\n                elif term_cls == PowerFeed:\n\n                    attrs[f'termination_{cable_end}_powerpanel'] = DynamicModelChoiceField(\n                        queryset=PowerPanel.objects.all(),\n                        label='Power Panel',\n                        required=False,\n                        initial_params={\n                            'powerfeeds__in': f'${cable_end}_terminations'\n                        },\n                        query_params={\n                            'site_id': f'$termination_{cable_end}_site',\n                            'location_id': f'$termination_{cable_end}_location',\n                        }\n                    )\n                    attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(\n                        queryset=term_cls.objects.all(),\n                        label='Power Feed',\n                        disabled_indicator='_occupied',\n                        query_params={\n                            'powerpanel_id': f'$termination_{cable_end}_powerpanel',\n                        }\n                    )\n\n                # CircuitTermination\n                elif term_cls == CircuitTermination:\n\n                    attrs[f'termination_{cable_end}_provider'] = DynamicModelChoiceField(\n                        queryset=Provider.objects.all(),\n                        label='Provider',\n                        initial_params={\n                            'circuits': f'$termination_{cable_end}_circuit'\n                        },\n                        required=False\n                    )\n                    attrs[f'termination_{cable_end}_circuit'] = DynamicModelChoiceField(\n                        queryset=Circuit.objects.all(),\n                        label='Circuit',\n                        initial_params={\n                            'terminations__in': f'${cable_end}_terminations'\n                        },\n                        query_params={\n                            'provider_id': f'$termination_{cable_end}_provider',\n                            'site_id': f'$termination_{cable_end}_site',\n                        }\n                    )\n                    attrs[f'{cable_end}_terminations'] = DynamicModelMultipleChoiceField(\n                        queryset=term_cls.objects.all(),\n                        label='Side',\n                        disabled_indicator='_occupied',\n                        query_params={\n                            'circuit_id': f'$termination_{cable_end}_circuit',\n                        }\n                    )\n\n            return super().__new__(mcs, name, bases, attrs)\n\n    class _CableForm(CableForm, metaclass=FormMetaclass):\n\n        def __init__(self, *args, **kwargs):\n\n            # TODO: Temporary hack to work around list handling limitations with utils.normalize_querydict()\n            for field_name in ('a_terminations', 'b_terminations'):\n                if field_name in kwargs.get('initial', {}) and type(kwargs['initial'][field_name]) is not list:\n                    kwargs['initial'][field_name] = [kwargs['initial'][field_name]]\n\n            super().__init__(*args, **kwargs)\n\n            if self.instance and self.instance.pk:\n                # Initialize A/B terminations when modifying an existing Cable instance\n                self.initial['a_terminations'] = self.instance.a_terminations\n                self.initial['b_terminations'] = self.instance.b_terminations\n\n        def clean(self):\n            super().clean()\n\n            # Set the A/B terminations on the Cable instance\n            self.instance.a_terminations = self.cleaned_data['a_terminations']\n            self.instance.b_terminations = self.cleaned_data['b_terminations']\n\n    return _CableForm\n", "path": "netbox/dcim/forms/connections.py"}]}