pub fn select_multiple_from<K: AsRef<str>, V: AsRef<str>>(
name: impl AsRef<str>,
options: impl IntoIterator<Item = (K, V)>,
selected: &[&str],
) -> ElementExpand description
A <select name="…" multiple> holding one <option> per (value, label) pair, with
every option whose value is in selected marked selected.
select_from is the single-choice form. This one exists because a multiple select
needs a set of selected values, not an Option; pass &[] when none is.
§Examples
use molt::prelude::*;
let tags = [("rust", "Rust"), ("wasm", "WebAssembly")];
assert_eq!(
select_multiple_from("tags", tags, &["rust"]).render(),
concat!(
r#"<select name="tags" multiple><option value="rust" selected>Rust</option>"#,
r#"<option value="wasm">WebAssembly</option></select>"#,
)
);