Skip to main content

FormProps

Struct FormProps 

Source
pub struct FormProps {
Show 17 fields pub children: Children, pub class: &'static str, pub style: &'static str, pub id: &'static str, pub action: &'static str, pub method: Method, pub enc_type: EncType, pub target: Target, pub novalidate: bool, pub autocomplete: &'static str, pub name: &'static str, pub validation_behavior: ValidationBehavior, pub on_submit: Option<Callback<SubmitEvent>>, pub on_reset: Option<Callback<Event>>, pub aria_label: &'static str, pub aria_labelledby: &'static str, pub data_testid: &'static str,
}
Available on crate feature lep only.
Expand description

Props for the Form component.

A semantic <form> wrapper that provides validation context to descendant fields.

Propagates FormContext via Leptos context so that Control, FormLabel, and Helper can read validation mode and submission state without prop drilling.

ยงAccessibility

  • Renders as a native <form> element (implicit "form" ARIA role).
  • Supply aria_label or aria_labelledby to create a named form landmark.

ยงExamples

use form_rs::leptos::{Form, Control, FormLabel};
use leptos::prelude::*;
use leptos::ev::SubmitEvent;

#[component]
pub fn LoginForm() -> impl IntoView {
    view! {
        <Form aria_label="Login" on_submit=Callback::new(|e: SubmitEvent| e.prevent_default())>
            <Control input_id="email">
                <FormLabel html_for="email">"Email"</FormLabel>
            </Control>
        </Form>
    }
}

ยงRequired Props

  • children: Children
    • Form content: fields, buttons, and other interactive controls.

ยงOptional Props

  • class: [&'static str]
    • Additional CSS class names on the <form> element.
  • style: [&'static str]
    • Inline CSS on the <form> element.
  • id: [&'static str]
    • id attribute on the <form> element.
  • action: [&'static str]
    • URL that processes the form submission.
  • method: Method
    • HTTP method for form submission.
  • enc_type: EncType
    • MIME encoding type for submitted data.
  • target: Target
    • Where to display the form response.
  • novalidate: bool
    • When true, disables native browser validation.
  • autocomplete: [&'static str]
    • Browser autocomplete hint.
  • name: [&'static str]
    • Name of the form.
  • validation_behavior: ValidationBehavior
    • Controls whether validation is native or ARIA-based.
  • on_submit: Callback<SubmitEvent>
    • Handler called when the form is submitted.
  • on_reset: Callback<Event>
    • Handler called when the form is reset.
  • aria_label: [&'static str]
    • Accessible label for screen readers.
  • aria_labelledby: [&'static str]
    • ID of element that labels this form.
  • data_testid: [&'static str]
    • data-testid for automated testing.

Fieldsยง

ยงchildren: Children

Form content: fields, buttons, and other interactive controls.

ยงclass: &'static str

Additional CSS class names on the <form> element.

ยงstyle: &'static str

Inline CSS on the <form> element.

ยงid: &'static str

id attribute on the <form> element.

ยงaction: &'static str

URL that processes the form submission.

ยงmethod: Method

HTTP method for form submission.

ยงenc_type: EncType

MIME encoding type for submitted data.

ยงtarget: Target

Where to display the form response.

ยงnovalidate: bool

When true, disables native browser validation.

ยงautocomplete: &'static str

Browser autocomplete hint.

ยงname: &'static str

Name of the form.

ยงvalidation_behavior: ValidationBehavior

Controls whether validation is native or ARIA-based.

ยงon_submit: Option<Callback<SubmitEvent>>

Handler called when the form is submitted.

ยงon_reset: Option<Callback<Event>>

Handler called when the form is reset.

ยงaria_label: &'static str

Accessible label for screen readers.

ยงaria_labelledby: &'static str

ID of element that labels this form.

ยงdata_testid: &'static str

data-testid for automated testing.

Implementationsยง

Sourceยง

impl FormProps

Source

pub fn builder() -> FormPropsBuilder<((), (), (), (), (), (), (), (), (), (), (), (), (), (), (), (), ())>

Create a builder for building FormProps. On the builder, call .children(...), .class(...)(optional), .style(...)(optional), .id(...)(optional), .action(...)(optional), .method(...)(optional), .enc_type(...)(optional), .target(...)(optional), .novalidate(...)(optional), .autocomplete(...)(optional), .name(...)(optional), .validation_behavior(...)(optional), .on_submit(...)(optional), .on_reset(...)(optional), .aria_label(...)(optional), .aria_labelledby(...)(optional), .data_testid(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of FormProps.

Trait Implementationsยง

Sourceยง

impl Props for FormProps

Sourceยง

type Builder = FormPropsBuilder

Sourceยง

fn builder() -> Self::Builder

Auto Trait Implementationsยง

Blanket Implementationsยง

Sourceยง

impl<Token, Builder, How> AllPropsFor<Builder, How> for Token
where Builder: Buildable<Token>, <Builder as Buildable<Token>>::WrappedToken: HasAllProps<<Builder as Buildable<Token>>::Output, How>,

Sourceยง

impl<T> Any for T
where T: 'static + ?Sized,

Sourceยง

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Sourceยง

impl<T> Borrow<T> for T
where T: ?Sized,

Sourceยง

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Sourceยง

impl<T> BorrowMut<T> for T
where T: ?Sized,

Sourceยง

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Sourceยง

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Sourceยง

impl<T> From<T> for T

Sourceยง

fn from(t: T) -> T

Returns the argument unchanged.

Sourceยง

impl<E, T, Request, Encoding> FromReq<Patch<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Sourceยง

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Sourceยง

impl<E, T, Request, Encoding> FromReq<Post<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Sourceยง

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Sourceยง

impl<E, T, Request, Encoding> FromReq<Put<Encoding>, Request, E> for T
where Request: Req<E> + Send + 'static, Encoding: Decodes<T>, E: FromServerFnError,

Sourceยง

async fn from_req(req: Request) -> Result<T, E>

Attempts to deserialize the arguments from a request.
Sourceยง

impl<E, Encoding, Response, T> FromRes<Patch<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Sourceยง

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Sourceยง

impl<E, Encoding, Response, T> FromRes<Post<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Sourceยง

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Sourceยง

impl<E, Encoding, Response, T> FromRes<Put<Encoding>, Response, E> for T
where Response: ClientRes<E> + Send, Encoding: Decodes<T>, E: FromServerFnError,

Sourceยง

async fn from_res(res: Response) -> Result<T, E>

Attempts to deserialize the outputs from a response.
Sourceยง

impl<T> HasAllProps<(), T> for T

Sourceยง

impl<T> InitializeFromFunction<T> for T

Sourceยง

fn initialize_from_function(f: fn() -> T) -> T

Create an instance of this type from an initialization function
Sourceยง

impl<T> Instrument for T

Sourceยง

fn instrument(self, span: Span) -> Instrumented<Self> โ“˜

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Sourceยง

fn in_current_span(self) -> Instrumented<Self> โ“˜

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Sourceยง

impl<T, U> Into<U> for T
where U: From<T>,

Sourceยง

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Sourceยง

impl<T> IntoEither for T

Sourceยง

fn into_either(self, into_left: bool) -> Either<Self, Self> โ“˜

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> โ“˜
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Sourceยง

impl<T> IntoPropValue<Option<T>> for T

Sourceยง

fn into_prop_value(self) -> Option<T>

Convert self to a value of a Properties struct.
Sourceยง

impl<T> IntoPropValue<T> for T

Sourceยง

fn into_prop_value(self) -> T

Convert self to a value of a Properties struct.
Sourceยง

impl<E, T, Encoding, Request> IntoReq<Patch<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Sourceยง

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Sourceยง

impl<E, T, Encoding, Request> IntoReq<Post<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Sourceยง

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Sourceยง

impl<E, T, Encoding, Request> IntoReq<Put<Encoding>, Request, E> for T
where Request: ClientReq<E>, Encoding: Encodes<T>, E: FromServerFnError,

Sourceยง

fn into_req(self, path: &str, accepts: &str) -> Result<Request, E>

Attempts to serialize the arguments into an HTTP request.
Sourceยง

impl<E, Response, Encoding, T> IntoRes<Patch<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Sourceยง

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Sourceยง

impl<E, Response, Encoding, T> IntoRes<Post<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Sourceยง

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Sourceยง

impl<E, Response, Encoding, T> IntoRes<Put<Encoding>, Response, E> for T
where Response: TryRes<E>, Encoding: Encodes<T>, E: FromServerFnError + Send, T: Send,

Sourceยง

async fn into_res(self) -> Result<Response, E>

Attempts to serialize the output into an HTTP response.
Sourceยง

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Sourceยง

impl<T> Same for T

Sourceยง

type Output = T

Should always be Self
Sourceยง

impl<T> SerializableKey for T

Sourceยง

fn ser_key(&self) -> String

Serializes the key to a unique string. Read more
Sourceยง

impl<Ret> SpawnIfAsync<(), Ret> for Ret

Sourceยง

fn spawn(self) -> Ret

Spawn the value into the dioxus runtime if it is an async block
Sourceยง

impl<T> StorageAccess<T> for T

Sourceยง

fn as_borrowed(&self) -> &T

Borrows the value.
Sourceยง

fn into_taken(self) -> T

Takes the value.
Sourceยง

impl<T, O> SuperFrom<T> for O
where O: From<T>,

Sourceยง

fn super_from(input: T) -> O

Convert from a type to another type.
Sourceยง

impl<T, O, M> SuperInto<O, M> for T
where O: SuperFrom<T, M>,

Sourceยง

fn super_into(self) -> O

Convert from a type to another type.
Sourceยง

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Sourceยง

type Error = !

The type returned in the event of a conversion error.
Sourceยง

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Sourceยง

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Sourceยง

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Sourceยง

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Sourceยง

impl<S, T> Upcast<T> for S
where T: UpcastFrom<S> + ?Sized, S: ?Sized,

Sourceยง

fn upcast(&self) -> &T
where Self: ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider ref type within the Wasm bindgen generics type system. Read more
Sourceยง

fn upcast_into(self) -> T
where Self: Sized + ErasableGeneric, T: Sized + ErasableGeneric<Repr = Self::Repr>,

Perform a zero-cost type-safe upcast to a wider type within the Wasm bindgen generics type system. Read more
Sourceยง

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Sourceยง

fn vzip(self) -> V

Sourceยง

impl<T> WithSubscriber for T

Sourceยง

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> โ“˜
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Sourceยง

fn with_current_subscriber(self) -> WithDispatch<Self> โ“˜

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more