0

The essence of the problem lies in the fact that there is a form on the html page, in which there can be a different number of input fields. Is it possible somehow to get all the values ​​entered by the user in those fields?

I can get the value ​​if it is known that the input field, for example, is only one:

#[derive(FromForm)]
 pub struct TableNameInput {
     pub table_name: String,
 }
#[post("/create_table", data = "<table_name>")]
    pub fn post_create_table(table_name: Form<TableNameInput>) -> Html<String> {
        let table = table_name.into_inner().table_name;
        let s = create_table(String::from("new_db"), table);

        Html(format!("<!DOCTYPE html>
        <html lang=\"en\">
        <head>
            <meta charset=\"UTF-8\">
            <meta name=\"viewport\" content=\"width=device-width, initial-scale=1.0\">
            <title>Document</title>
            <script src=\"../static/js/index.js\"></script>
        </head>
        <body>
            <link rel=\"stylesheet\" type=\"text/css\" href=\"../static/styles/style.css\"></link>   
            <h3>{}</h3>
        </body>
        </html>", s))
 }

In this code i take table's name from input field and insert it in "h3" tag. But how can i get all entered values ​​if i don't know number of input fields.

Jmb
  • 18,893
  • 2
  • 28
  • 55
acvel
  • 3
  • 2
  • Have you tried `fields: Form>`? – Ivan C Aug 29 '23 at 13:08
  • Also it looks like you're dynamically creating database tables based on user input. This is very much not a thing that's recommended to do. – Ivan C Aug 29 '23 at 13:09
  • @IvanC Sorry for the long answer, yes I tried this but after running I got an error `422: Unprocessable Entity` on my page` – acvel Aug 31 '23 at 07:16

0 Answers0