Skip to main content

bind_form

Function bind_form 

Source
pub fn bind_form(form: &mut FormConfig, params: &HashMap<String, String>)
Expand description

Pull submitted values out of a parsed urlencoded body and write them into the form’s fields.

  • Non-Boolean: the field’s value is set to the matching params entry if present, otherwise left as-is.
  • Boolean: HTML form submission omits unchecked checkboxes / switches entirely, so the rule is presence-of-key, not value: value = Some(params.contains_key(name).to_string()).

Pre-existing per-field errors are cleared so subsequent calls to validate_form start from a clean slate. The form’s submitted flag flips to true so render_form can swap the error summary for the .form-success banner when validation passes.

Never panics; missing keys silently leave non-boolean fields untouched.