pub struct DateField {
pub name: String,
pub label: Option<String>,
pub required: bool,
pub help_text: Option<String>,
pub widget: Widget,
pub initial: Option<Value>,
pub input_formats: Vec<String>,
pub localize: bool,
pub locale: Option<String>,
}Expand description
DateField for date input
Fields§
§name: StringThe field name used as the form data key.
label: Option<String>Optional human-readable label for display.
required: boolWhether this field must be filled in.
help_text: Option<String>Optional help text displayed alongside the field.
widget: WidgetThe widget type used for rendering this field.
initial: Option<Value>Optional initial (default) value for the field.
input_formats: Vec<String>Accepted date format strings (strftime patterns).
localize: boolWhether to apply locale-aware formatting.
locale: Option<String>The locale to use for formatting (e.g., “en_US”).
Implementations§
Source§impl DateField
impl DateField
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
Create a new DateField with the given name
§Examples
use reinhardt_forms::fields::DateField;
let field = DateField::new("birth_date".to_string());
assert_eq!(field.name, "birth_date");
assert!(field.required);Sourcepub fn with_localize(self, localize: bool) -> Self
pub fn with_localize(self, localize: bool) -> Self
Enable localization for this field
§Examples
use reinhardt_forms::fields::DateField;
let field = DateField::new("date".to_string()).with_localize(true);
assert!(field.localize);Sourcepub fn with_locale(self, locale: String) -> Self
pub fn with_locale(self, locale: String) -> Self
Set the locale for this field
§Examples
use reinhardt_forms::fields::DateField;
let field = DateField::new("date".to_string()).with_locale("en_US".to_string());
assert_eq!(field.locale, Some("en_US".to_string()));Trait Implementations§
Source§impl FormField for DateField
impl FormField for DateField
Source§fn initial(&self) -> Option<&Value>
fn initial(&self) -> Option<&Value>
Returns the initial (default) value for this field, if any.
Source§fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
Validates and cleans the submitted value, returning the cleaned result.
Auto Trait Implementations§
impl Freeze for DateField
impl RefUnwindSafe for DateField
impl Send for DateField
impl Sync for DateField
impl Unpin for DateField
impl UnsafeUnpin for DateField
impl UnwindSafe for DateField
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