form.rs 871 B

12345678910111213141516171819202122232425262728
  1. //! Forms
  2. //!
  3. //! Dioxus forms deviate slightly from html, automatically returning all named inputs
  4. //! in the "values" field.
  5. use dioxus::prelude::*;
  6. fn main() {
  7. launch_desktop(app);
  8. }
  9. fn app() -> Element {
  10. rsx! {
  11. div {
  12. h1 { "Form" }
  13. form {
  14. onsubmit: move |ev| println!("Submitted {:?}", ev.values()),
  15. oninput: move |ev| println!("Input {:?}", ev.values()),
  16. input { r#type: "text", name: "username" }
  17. input { r#type: "text", name: "full-name" }
  18. input { r#type: "password", name: "password" }
  19. input { r#type: "radio", name: "color", value: "red" }
  20. input { r#type: "radio", name: "color", value: "blue" }
  21. button { r#type: "submit", value: "Submit", "Submit the form" }
  22. }
  23. }
  24. }
  25. }