println!("{:?}", form);
+ writeln!(output, "use serde::{{Serialize, Deserialize}};");
+ writeln!(output, "");
+
writeln!(output, "use zakform::fields::{{TField, FOption}};");
writeln!(output, "");
writeln!(output, "let mut f = zakform::form::Form::new();");
+ let mut struct_form = String::new();
+
for e in form.elements {
writeln!(output, "");
+ if e.etype.as_str() == "zak_form_cgi_form_element_submit" {
+ struct_form.push_str(&format!("pub {}: Option<String>,\n", e.id));
+ } else {
+ struct_form.push_str(&format!("pub {}: String,\n", e.id));
+ }
+
match e.etype.as_str() {
"zak_form_cgi_form_element_text"
| "zak_form_cgi_form_element_email" => { writeln!(output, r#"let mut fi = zakform::fields::FieldText::new("{}");"#, e.id); },
writeln!(output, "");
writeln!(output, "f");
writeln!(output, "}}");
+
+ /* form struct */
+ writeln!(output, "");
+ writeln!(output, "#[derive(Debug, Serialize, Deserialize)]");
+ writeln!(output, "pub struct DomandaForm {{");
+ writeln!(output, "{}}}", struct_form);
+
}