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>
impl<T: Clone + PartialEq + 'static> FormField<T>
Sourcepub fn new(
id: impl Into<String>,
name: impl Into<String>,
label: impl Into<String>,
initial_value: T,
rules: Vec<ValidationRule<T>>,
) -> Self
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.
Sourcepub fn with_placeholder(self, placeholder: impl Into<String>) -> Self
pub fn with_placeholder(self, placeholder: impl Into<String>) -> Self
Sets the placeholder text for this field.
Sourcepub fn with_helper_text(self, helper: impl Into<String>) -> Self
pub fn with_helper_text(self, helper: impl Into<String>) -> Self
Sets the helper text displayed below the field.
Sourcepub fn with_input_type(self, input_type: impl Into<String>) -> Self
pub fn with_input_type(self, input_type: impl Into<String>) -> Self
Sets the HTML input type (e.g. “text”, “email”, “password”, “number”).
Trait Implementations§
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>
impl<T> Unpin for FormField<T>
impl<T> UnsafeUnpin for FormField<T>where
Signal<T>: UnsafeUnpin,
Vec<Rc<dyn Fn(&T) -> Result<(), String>>>: UnsafeUnpin,
T: UnsafeUnpin,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more