Skip to content

Commit

Permalink
Closes #17776: Add support for different HTTP methods to HTMXSelect
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremystretch committed Oct 16, 2024
1 parent dbc52dc commit 0a5bf21
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions netbox/utilities/forms/widgets/select.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,12 @@ class HTMXSelect(forms.Select):
"""
Selection widget that will re-generate the HTML form upon the selection of a new option.
"""
def __init__(self, hx_url='.', hx_target_id='form_fields', attrs=None, **kwargs):
def __init__(self, method='get', hx_url='.', hx_target_id='form_fields', attrs=None, **kwargs):
method = method.lower()
if method not in ('delete', 'get', 'patch', 'post', 'put'):
raise ValueError(f"Unsupported HTTP method: {method}")
_attrs = {
'hx-get': hx_url,
f'hx-{method}': hx_url,
'hx-include': f'#{hx_target_id}',
'hx-target': f'#{hx_target_id}',
}
Expand Down

0 comments on commit 0a5bf21

Please sign in to comment.