mirror of
https://github.com/netbox-community/netbox.git
synced 2025-07-14 01:41:22 -06:00
Closes #17776: Add support for different HTTP methods to HTMXSelect
This commit is contained in:
parent
dbc52dc6c7
commit
e7bd0e53d7
@ -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}',
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user