radio
Displays a radio select input widget and maps its value to the backend as a string.
Basic use¶
{% htmx_radio name="my_input" %}
from simmate.website.htmx.components import HtmxComponent
class ExampleView(HtmxComponent):
my_input = None
my_input_options = [
("label1", "value1"),
("label2", "value2"),
("label3", "value3"),
# ...
]
Parameters¶
| Parameter | Description |
|---|---|
name |
The unique name or identifier for the input field. This should match the name of your class attribute in the backend. Type: str, Default: — |
options |
The name of the class attribute that holds all options for the dropdown menu. In python, options should be a list of ('label', 'value'), where label is what's shown in the UI and value is what is set in python.Type: str, Default: `f"{name}_options" |
label |
The display label for the input field. If not provided, the name may be used as the label.Type: str, Default: None |
show_label |
Whether to display the label alongside the input field. Type: bool, Default: True |
defer |
Whether to defer processing or submission of the input value. Type: bool, Default: True |
required |
Whether the field is required for form submission. Type: bool, Default: False |