Skip to main content

select_named

Function select_named 

Source
pub fn select_named(name: impl AsRef<str>) -> Element
Expand description

A <select name="…">.

Fill it with options_from through Element::children_from, or with optgroup_labeled groups. select_from does the ungrouped case in one call.

§Examples

use molt::prelude::*;
let options = options_from([("poa", "Porto Alegre")], None);
let south = optgroup_labeled("Sul").children_from(options);
let select = select_named("city").child(south);
assert_eq!(
    select.render(),
    concat!(
        r#"<select name="city"><optgroup label="Sul">"#,
        r#"<option value="poa">Porto Alegre</option></optgroup></select>"#,
    )
);