DioxusLabs / DioxusLabs/dioxus
"Dioxus v0.7.0-alpha.1 Desktop Login Form: onsubmit Event Fails to Trigger Submission"
- Dominant language
- Rust
- Stars
- 39.1k
- Forks
- 1.9k
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 4
Description
**Problem**
I'm working on implementing a login form in a Dioxus desktop application with version v0.7.0 - alpha.1. However, the form submission is not working as expected. When I click the submit button, the `onsubmit` event in the form doesn't seem to trigger any action, and the form data is not sent to the server.
Here is the relevant code snippet for the form:
```rust
use dioxus::prelude::*;
fn main() {
dioxus::launch(app);
}
fn app() -> Element {
let onsubmit = move |evt: FormEvent| async move {
let resp = reqwest::Client::new()
.post("http://localhost:8080/login")
.form(&[
("username", evt.values()["username"].as_value()),
("password", evt.values()["password"].as_value()),
])
.send()
.await;
match resp {
// Parse data from here, such as storing a response token
Ok(_data) => println!("Login successful!"),
//Handle any errors from the fetch here
Err(_err) => {
println!("Login failed - you need a login server running on localhost:8080.")
}
}
};
rsx! {
h1 { "Login" }
form { onsubmit,
input { r#type: "text", id: "username", name: "username" }
label { "Username" }
br {}
input { r#type: "password", id: "password", name: "password" }
label { "Password" }
br {}
button { "Login" }
}
}
}
```
**Steps To Reproduce**
Steps to reproduce the behavior:
- Create a new Dioxus desktop project.
- Copy the above code into the main.rs file.
- Run the application using cargo run.
- Enter a valid username and password in the form fields.
- Click the "Login" button.
**Expected behavior**
When the "Login" button is clicked, the form data should be sent to the server at http://localhost:8080/login. Depending on the server response, either "Login successful!" or "Login failed - you need a login server running on [localhost:8080](https://localhost:8080/)." should be printed in the console.
**Screenshots**
Not applicable at the moment.
**Environment:**
Dioxus version: v0.7.0 - alpha.1
Rust version: rustup 1.28.2 (e4f3ad6f8 2025-04-28),rustc 1.89.0-nightly (45acf54ee 2025-06-16)
OS info: Win11 24H2
App platform: desktop
**Questionnaire**
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.