Skip to main content

FormField

Struct FormField 

Source
pub struct FormField<T: Clone + PartialEq + 'static> {
    pub id: String,
    pub name: String,
    pub label: String,
    pub placeholder: String,
    pub helper_text: String,
    pub input_type: String,
    pub value: Signal<T>,
    pub error: Signal<Option<String>>,
    pub touched: Signal<bool>,
    pub dirty: Signal<bool>,
    pub is_valid: Signal<bool>,
    /* private fields */
}
Expand description

A reactive form field containing independent state signals.

Fields§

§id: String§name: String§label: String§placeholder: String§helper_text: String§input_type: String§value: Signal<T>§error: Signal<Option<String>>§touched: Signal<bool>§dirty: Signal<bool>§is_valid: Signal<bool>

Implementations§

Source§

impl<T: Clone + PartialEq + 'static> FormField<T>

Source

pub fn new( id: impl Into<String>, name: impl Into<String>, label: impl Into<String>, initial_value: T, rules: Vec<ValidationRule<T>>, ) -> Self

Creates a new FormField with initial value and validation rules.

Source

pub fn with_placeholder(self, placeholder: impl Into<String>) -> Self

Sets the placeholder text for this field.

Source

pub fn with_helper_text(self, helper: impl Into<String>) -> Self

Sets the helper text displayed below the field.

Source

pub fn with_input_type(self, input_type: impl Into<String>) -> Self

Sets the HTML input type (e.g. “text”, “email”, “password”, “number”).

Source

pub fn set_value(&self, val: T)

Sets the current field value, marks dirty flag, and triggers validation.

Source

pub fn touch(&self)

Marks the field as touched (focused and blurred).

Source

pub fn validate(&self) -> bool

Validates the current value against all configured rules.

Source

pub fn reset(&self)

Resets the field to its initial value, clearing error and dirty states.

Source§

impl FormField<String>

Source

pub fn render(&self) -> DomBuilder

Renders an enterprise WCAG 2.1 AA compliant text/email/password/number input group.

Trait Implementations§

Source§

impl<T: Clone + Clone + PartialEq + 'static> Clone for FormField<T>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more

Auto Trait Implementations§

§

impl<T> !RefUnwindSafe for FormField<T>

§

impl<T> !Send for FormField<T>

§

impl<T> !Sync for FormField<T>

§

impl<T> !UnwindSafe for FormField<T>

§

impl<T> Freeze for FormField<T>
where Signal<T>: Freeze, Vec<Rc<dyn Fn(&T) -> Result<(), String>>>: Freeze, T: Freeze,

§

impl<T> Unpin for FormField<T>
where Signal<T>: Unpin, Vec<Rc<dyn Fn(&T) -> Result<(), String>>>: Unpin, T: Unpin,

§

impl<T> UnsafeUnpin for FormField<T>

Blanket Implementations§

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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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