1use dioxus::prelude::*;
2
3#[derive(Clone, PartialEq)]
4pub enum FormMethod {
5 Get,
6 Post,
7 None,
8}
9
10impl From<FormMethod> for &str {
11 fn from(value: FormMethod) -> Self {
12 match value {
13 FormMethod::Get => "get",
14 FormMethod::Post => "post",
15 _ => "",
16 }
17 }
18}
19
20#[derive(Clone, Props, PartialEq)]
21pub struct FormProps {
22 #[props(optional)]
23 id: String,
24 #[props(optional, default = "".to_string())]
25 class: String,
26 #[props(optional, default = false)]
27 disabled: bool,
28 #[props(optional, default = None)]
29 action: Option<String>,
30 #[props(optional, default = FormMethod::None)]
31 method: FormMethod,
32 children: Element,
33}
34
35#[component]
36pub fn Form(props: FormProps) -> Element {
37 let method: &str = props.method.into();
40 rsx!{
41 form {
42 id: props.id,
43 class: props.class,
44 action: props.action,
45 method: method,
46 fieldset {
47 disabled: props.disabled,
48 {props.children}
49 }
50 }
51 }
52}