Skip to main content

FieldProps

Struct FieldProps 

Source
pub struct FieldProps {
Show 22 fields pub id: &'static str, pub name: &'static str, pub type: &'static str, pub label: &'static str, pub placeholder: &'static str, pub helper_text: &'static str, pub validation_state: ValidationState, pub required: bool, pub disabled: bool, pub full_width: bool, pub variant: Variant, pub color: Color, pub size: Size, pub pattern: &'static str, pub maxlength: Option<usize>, pub minlength: Option<usize>, pub class: &'static str, pub style: &'static str, pub handle: RwSignal<String>, pub valid_handle: RwSignal<bool>, pub validate_function: fn(String) -> bool, pub data_testid: &'static str,
}
Available on crate feature lep only.
Expand description

Props for the Field component.

A convenience composition of Control, FormLabel, Input, and Helper into a single validated form field for Leptos.

Uses input-rs for the underlying <input> element with HTML5 validation.

ยงExamples

use form_rs::leptos::Field;
use leptos::prelude::*;

#[component]
pub fn EmailInput() -> impl IntoView {
    let handle = RwSignal::new(String::new());
    let valid = RwSignal::new(true);
    view! {
        <Field
            id="email"
            name="email"
            r#type="email"
            label="Email address"
            placeholder="ferris@opensass.org"
            required=true
            handle=handle
            valid_handle=valid
            validate_function=|v: String| !v.is_empty() && v.contains('@')
        />
    }
}

ยงRequired Props

  • id: [&'static str]
    • The unique id for the <input> element.
  • handle: RwSignal<String>
    • Controlled value signal.
  • valid_handle: RwSignal<bool>
    • Validity signal.
  • validate_function: [fn(String) -> bool]
    • Validation function.

ยงOptional Props

  • name: [&'static str]
    • The name attribute for the <input>.
  • r#type: [&'static str]
    • The input type.
  • label: [&'static str]
    • Label text displayed above the input.
  • placeholder: [&'static str]
    • Placeholder text.
  • helper_text: [&'static str]
    • Helper text below the input.
  • validation_state: ValidationState
    • Validation state.
  • required: bool
    • Whether the field is required.
  • disabled: bool
    • Whether the field is disabled.
  • full_width: bool
    • Whether the field takes the full container width.
  • variant: Variant
    • Visual variant.
  • color: Color
    • Color theme.
  • size: Size
    • Size.
  • pattern: [&'static str]
    • HTML5 pattern for native regex validation.
  • maxlength: usize
    • Max character count.
  • minlength: usize
    • Min character count.
  • class: [&'static str]
    • Outer <div> CSS class.
  • style: [&'static str]
    • Outer <div> inline CSS.
  • data_testid: [&'static str]
    • data-testid for automated testing.

Fieldsยง

ยงid: &'static str

The unique id for the <input> element.

ยงname: &'static str

The name attribute for the <input>.

ยงtype: &'static str

The input type.

ยงlabel: &'static str

Label text displayed above the input.

ยงplaceholder: &'static str

Placeholder text.

ยงhelper_text: &'static str

Helper text below the input.

ยงvalidation_state: ValidationState

Validation state.

ยงrequired: bool

Whether the field is required.

ยงdisabled: bool

Whether the field is disabled.

ยงfull_width: bool

Whether the field takes the full container width.

ยงvariant: Variant

Visual variant.

ยงcolor: Color

Color theme.

ยงsize: Size

Size.

ยงpattern: &'static str

HTML5 pattern for native regex validation.

ยงmaxlength: Option<usize>

Max character count.

ยงminlength: Option<usize>

Min character count.

ยงclass: &'static str

Outer <div> CSS class.

ยงstyle: &'static str

Outer <div> inline CSS.

ยงhandle: RwSignal<String>

Controlled value signal.

ยงvalid_handle: RwSignal<bool>

Validity signal.

ยงvalidate_function: fn(String) -> bool

Validation function.

ยงdata_testid: &'static str

data-testid for automated testing.

Implementationsยง

Sourceยง

impl FieldProps

Source

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

Create a builder for building FieldProps. On the builder, call .id(...), .name(...)(optional), .r#type(...)(optional), .label(...)(optional), .placeholder(...)(optional), .helper_text(...)(optional), .validation_state(...)(optional), .required(...)(optional), .disabled(...)(optional), .full_width(...)(optional), .variant(...)(optional), .color(...)(optional), .size(...)(optional), .pattern(...)(optional), .maxlength(...)(optional), .minlength(...)(optional), .class(...)(optional), .style(...)(optional), .handle(...), .valid_handle(...), .validate_function(...), .data_testid(...)(optional) to set the values of the fields. Finally, call .build() to create the instance of FieldProps.

Trait Implementationsยง

Sourceยง

impl Props for FieldProps

Sourceยง

type Builder = FieldPropsBuilder

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