pub struct Field {
pub name: String,
pub label: String,
pub field_type: FieldType,
pub readonly: bool,
pub hidden: bool,
pub list_only: bool,
pub form_only: bool,
pub required: bool,
pub help_text: Option<String>,
pub validators: Vec<Box<dyn Validator>>,
pub async_validators: Vec<Box<dyn AsyncValidator>>,
}Fields§
§name: String§label: String§field_type: FieldType§readonly: bool§list_only: bool§form_only: bool§required: bool§help_text: Option<String>§validators: Vec<Box<dyn Validator>>§async_validators: Vec<Box<dyn AsyncValidator>>Implementations§
Source§impl Field
impl Field
pub fn text(name: &str) -> Self
pub fn textarea(name: &str) -> Self
pub fn email(name: &str) -> Self
pub fn password(name: &str) -> Self
pub fn number(name: &str) -> Self
pub fn float(name: &str) -> Self
pub fn boolean(name: &str) -> Self
pub fn date(name: &str) -> Self
pub fn datetime(name: &str) -> Self
pub fn json(name: &str) -> Self
pub fn select(name: &str, options: Vec<(String, String)>) -> Self
pub fn foreign_key( name: &str, label: &str, adapter: Box<dyn DataAdapter>, value_field: &str, label_field: &str, ) -> Self
pub fn custom(name: &str, widget: Box<dyn Widget>) -> Self
pub fn many_to_many(name: &str, adapter: Box<dyn ManyToManyAdapter>) -> Self
pub fn file(name: &str, storage: Arc<dyn FileStorage>) -> Self
pub fn image(name: &str, storage: Arc<dyn FileStorage>) -> Self
Sourcepub fn accept(self, types: Vec<String>) -> Self
pub fn accept(self, types: Vec<String>) -> Self
Set the accepted MIME types for a File field. Example: vec!["application/pdf".to_string()].
Has no effect on non-File fields.
pub fn label(self, label: &str) -> Self
pub fn readonly(self) -> Self
pub fn list_only(self) -> Self
pub fn form_only(self) -> Self
pub fn required(self) -> Self
pub fn help_text(self, text: &str) -> Self
Sourcepub fn async_validator(self, v: Box<dyn AsyncValidator>) -> Self
pub fn async_validator(self, v: Box<dyn AsyncValidator>) -> Self
Add a custom asynchronous validator (e.g. uniqueness checks).
pub fn min_length(self, n: usize) -> Self
pub fn max_length(self, n: usize) -> Self
pub fn min_value(self, n: f64) -> Self
pub fn max_value(self, n: f64) -> Self
pub fn regex(self, pattern: &str) -> Self
pub fn unique(self, adapter: Box<dyn DataAdapter>, col: &str) -> Self
pub fn fk_limit(self, n: u64) -> Self
pub fn fk_order_by(self, field: &str) -> Self
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Field
impl !RefUnwindSafe for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin for Field
impl !UnwindSafe for Field
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