Skip to content

Commit 17ba89e

Browse files
committed
Dropdown placeholders use "Select..." with disabled+hidden
The default empty option in <select> fields is "Select..." instead of "-- Select --". The option is disabled, selected, and hidden so users can't re-select it after making a choice. Follows the standard UX pattern for placeholder options in modern forms.
1 parent a592fa3 commit 17ba89e

2 files changed

Lines changed: 2 additions & 2 deletions

File tree

src/airform/forms.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -285,7 +285,7 @@ def default_form_widget(
285285
elif input_type == "select":
286286
options = _get_options(annotation, meta)
287287
parts.append(f" <select{_attr_str(input_attrs)}>")
288-
parts.append(' <option value="">-- Select --</option>')
288+
parts.append(' <option value="" disabled selected hidden>Select...</option>')
289289
for opt_val, opt_label in options:
290290
sel = " selected" if value is not None and str(value) == opt_val else ""
291291
parts.append(f' <option value="{escape(opt_val)}"{sel}>{escape(opt_label)}</option>')

tests/test_airform.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -384,7 +384,7 @@ class CompanionForm(AirForm[CompanionModel]):
384384
assert "<select" in html
385385
assert '<option value="tank">The One Who Gets Hit</option>' in html
386386
assert '<option value="bard">The One With Snacks</option>' in html
387-
assert '<option value="">-- Select --</option>' in html
387+
assert "Select...</option>" in html
388388

389389

390390
def test_render_airfield_choices_with_selected() -> None:

0 commit comments

Comments
 (0)