field-select
field's envelope around a native select. Past ten options the select arms the filterable combobox in select.js; the native select is still what the form submits.
Three options: a native select
Put this inside <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="sel_few" >Role</label >
<select rst-input id ="sel_few" name ="sel_few" >
<option value ="admin" selected >Admin</option >
<option value ="editor" >Editor</option >
<option value ="member" >Member</option >
</select >
</div >
Put this inside <section rst-box><form rst-form>.
{{ template "field-select" dict
"ID" "sel_few"
"Name" "sel_few"
"Label" "Role"
"Options" (list
(dict "Label" "Admin" "Selected" true "Value" "admin" )
(dict "Label" "Editor" "Value" "editor" )
(dict "Label" "Member" "Value" "member" ))}}
Twelve options: the filterable combobox
Put this inside <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="sel_many" >City</label >
<select rst-input id ="sel_many" name ="sel_many" data-rst-select data-rst-select-filter ="Type to filter" data-rst-select-results ="{n} results" data-rst-select-result-one ="1 result" data-rst-select-no-matches ="No matches" aria-describedby ="sel_many-help" >
<option value ="dublin" selected >Dublin</option >
<option value ="lisbon" >Lisbon</option >
<option value ="madrid" >Madrid</option >
<option value ="berlin" >Berlin</option >
<option value ="rome" >Rome</option >
<option value ="athens" >Athens</option >
<option value ="helsinki" >Helsinki</option >
<option value ="reykjavík" >Reykjavík</option >
<option value ="warsaw" >Warsaw</option >
<option value ="zagreb" >Zagreb</option >
<option value ="tallinn" >Tallinn</option >
<option value ="valletta" >Valletta</option >
</select >
<p rst-field-help id ="sel_many-help" >Start typing to filter.</p >
</div >
Put this inside <section rst-box><form rst-form>.
{{ template "field-select" dict
"ID" "sel_many"
"Name" "sel_many"
"Label" "City"
"Options" (list
(dict "Label" "Dublin" "Selected" true "Value" "dublin" )
(dict "Label" "Lisbon" "Value" "lisbon" )
(dict "Label" "Madrid" "Value" "madrid" )
(dict "Label" "Berlin" "Value" "berlin" )
(dict "Label" "Rome" "Value" "rome" )
(dict "Label" "Athens" "Value" "athens" )
(dict "Label" "Helsinki" "Value" "helsinki" )
(dict "Label" "Reykjavík" "Value" "reykjavík" )
(dict "Label" "Warsaw" "Value" "warsaw" )
(dict "Label" "Zagreb" "Value" "zagreb" )
(dict "Label" "Tallinn" "Value" "tallinn" )
(dict "Label" "Valletta" "Value" "valletta" ))
"Help" "Start typing to filter." }}
Past ten options the partial arms select.js. Below ten it does not: search over a handful of items is furniture, not help.
Twelve options, Plain: the enhancement opted out
Put this inside <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="sel_plain" >City</label >
<select rst-input id ="sel_plain" name ="sel_plain" >
<option value ="dublin" selected >Dublin</option >
<option value ="lisbon" >Lisbon</option >
<option value ="madrid" >Madrid</option >
<option value ="berlin" >Berlin</option >
<option value ="rome" >Rome</option >
<option value ="athens" >Athens</option >
<option value ="helsinki" >Helsinki</option >
<option value ="reykjavík" >Reykjavík</option >
<option value ="warsaw" >Warsaw</option >
<option value ="zagreb" >Zagreb</option >
<option value ="tallinn" >Tallinn</option >
<option value ="valletta" >Valletta</option >
</select >
</div >
Put this inside <section rst-box><form rst-form>.
{{ template "field-select" dict
"ID" "sel_plain"
"Name" "sel_plain"
"Label" "City"
"Options" (list
(dict "Label" "Dublin" "Selected" true "Value" "dublin" )
(dict "Label" "Lisbon" "Value" "lisbon" )
(dict "Label" "Madrid" "Value" "madrid" )
(dict "Label" "Berlin" "Value" "berlin" )
(dict "Label" "Rome" "Value" "rome" )
(dict "Label" "Athens" "Value" "athens" )
(dict "Label" "Helsinki" "Value" "helsinki" )
(dict "Label" "Reykjavík" "Value" "reykjavík" )
(dict "Label" "Warsaw" "Value" "warsaw" )
(dict "Label" "Zagreb" "Value" "zagreb" )
(dict "Label" "Tallinn" "Value" "tallinn" )
(dict "Label" "Valletta" "Value" "valletta" ))
"Plain" true }}
Required, with an error
Put this inside <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="sel_error" >Role</label >
<select rst-input id ="sel_error" name ="sel_error" required aria-invalid ="true" aria-describedby ="sel_error-error" >
<option value ="admin" selected >Admin</option >
<option value ="editor" >Editor</option >
<option value ="member" >Member</option >
</select >
<p rst-field-error id ="sel_error-error" role ="alert" >Pick a role for this person.</p >
</div >
Put this inside <section rst-box><form rst-form>.
{{ template "field-select" dict
"ID" "sel_error"
"Name" "sel_error"
"Label" "Role"
"Options" (list
(dict "Label" "Admin" "Selected" true "Value" "admin" )
(dict "Label" "Editor" "Value" "editor" )
(dict "Label" "Member" "Value" "member" ))
"Required" true
"Error" "Pick a role for this person." }}
Hand-written, with optgroups
Put this inside <section rst-box><form rst-form>.
<div rst-field >
<label rst-field-label for ="sel_grouped" >Region</label >
<select rst-input id ="sel_grouped" name ="sel_grouped" data-rst-select data-rst-select-filter ="Type to filter" data-rst-select-results ="{n} results" data-rst-select-result-one ="1 result" data-rst-select-no-matches ="No matches" >
<optgroup label ="Europe" >
<option value ="dublin" selected >Dublin</option >
<option value ="lisbon" >Lisbon</option >
<option value ="warsaw" >Warsaw</option >
</optgroup >
<optgroup label ="Americas" >
<option value ="montreal" >Montréal</option >
<option value ="lima" >Lima</option >
<option value ="austin" >Austin</option >
</optgroup >
<optgroup label ="Asia" >
<option value ="osaka" >Osaka</option >
<option value ="hanoi" >Hanoi</option >
<option value ="dhaka" >Dhaka</option >
</optgroup >
<optgroup label ="Africa" >
<option value ="accra" >Accra</option >
<option value ="nairobi" >Nairobi</option >
<option value ="tunis" >Tunis</option >
</optgroup >
</select >
</div >
Options here is a flat list, so grouped choices are markup the app writes. select.js renders the groups rather than dropping them; a hand-written select can also refuse the enhancement outright with data-rst-select="false".