pub struct FileField {
pub name: String,
pub label: Option<String>,
pub required: bool,
pub help_text: Option<String>,
pub widget: Widget,
pub initial: Option<Value>,
pub max_length: Option<usize>,
pub allow_empty_file: bool,
pub max_size: u64,
}Expand description
FileField for file upload
Fields§
§name: StringThe field name used as the form data key.
label: Option<String>Optional human-readable label for display.
required: boolWhether a file must be uploaded.
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.
max_length: Option<usize>Maximum allowed filename length.
allow_empty_file: boolWhether to accept empty (zero-byte) files.
max_size: u64Maximum file size in bytes. Defaults to 10 MB.
Implementations§
Source§impl FileField
impl FileField
Sourcepub fn new(name: String) -> Self
pub fn new(name: String) -> Self
Create a new FileField
§Examples
use reinhardt_forms::fields::FileField;
let field = FileField::new("upload".to_string());
assert_eq!(field.name, "upload");
assert_eq!(field.max_size, 10 * 1024 * 1024);Sourcepub fn with_max_size(self, max_size: u64) -> Self
pub fn with_max_size(self, max_size: u64) -> Self
Set the maximum file size in bytes.
§Examples
use reinhardt_forms::fields::FileField;
let field = FileField::new("upload".to_string()).with_max_size(5 * 1024 * 1024);
assert_eq!(field.max_size, 5 * 1024 * 1024);Trait Implementations§
Source§impl FormField for FileField
impl FormField for FileField
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 FileField
impl RefUnwindSafe for FileField
impl Send for FileField
impl Sync for FileField
impl Unpin for FileField
impl UnsafeUnpin for FileField
impl UnwindSafe for FileField
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