pub struct FieldDefinition {Show 20 fields
pub name: String,
pub label: String,
pub field_type: FieldType,
pub widget: WidgetType,
pub required: bool,
pub readonly: bool,
pub primary_key: bool,
pub list_display: bool,
pub searchable: bool,
pub filterable: bool,
pub sortable: bool,
pub default: Option<String>,
pub help_text: Option<String>,
pub placeholder: Option<String>,
pub validators: Vec<ValidatorType>,
pub choices: Option<Vec<Choice>>,
pub foreign_key: Option<ForeignKeyRef>,
pub max_length: Option<usize>,
pub min_value: Option<f64>,
pub max_value: Option<f64>,
}Expand description
Field definition for a model
Fields§
§name: StringField name
label: StringDisplay label
field_type: FieldTypeField type
widget: WidgetTypeWidget type for rendering
required: boolIs this field required?
readonly: boolIs this field read-only?
primary_key: boolIs this the primary key?
list_display: boolShow in list view?
searchable: boolSearchable?
filterable: boolFilterable?
sortable: boolSortable?
default: Option<String>Default value
help_text: Option<String>Help text
placeholder: Option<String>Placeholder text
validators: Vec<ValidatorType>Validation rules
choices: Option<Vec<Choice>>Choices for select fields
foreign_key: Option<ForeignKeyRef>Foreign key reference
max_length: Option<usize>Maximum length (for strings)
min_value: Option<f64>Minimum value (for numbers)
max_value: Option<f64>Maximum value (for numbers)
Implementations§
Source§impl FieldDefinition
impl FieldDefinition
Sourcepub fn new(name: impl Into<String>, field_type: FieldType) -> Self
pub fn new(name: impl Into<String>, field_type: FieldType) -> Self
Create a new field definition
Sourcepub fn primary_key(self) -> Self
pub fn primary_key(self) -> Self
Set as primary key
Sourcepub fn widget(self, widget: WidgetType) -> Self
pub fn widget(self, widget: WidgetType) -> Self
Set widget type
Sourcepub fn placeholder(self, text: impl Into<String>) -> Self
pub fn placeholder(self, text: impl Into<String>) -> Self
Set placeholder
Sourcepub fn validator(self, validator: ValidatorType) -> Self
pub fn validator(self, validator: ValidatorType) -> Self
Add validator
Sourcepub fn foreign_key(
self,
model: impl Into<String>,
display_field: impl Into<String>,
) -> Self
pub fn foreign_key( self, model: impl Into<String>, display_field: impl Into<String>, ) -> Self
Set foreign key
Sourcepub fn searchable(self) -> Self
pub fn searchable(self) -> Self
Enable search
Sourcepub fn filterable(self) -> Self
pub fn filterable(self) -> Self
Enable filter
Sourcepub fn hide_from_list(self) -> Self
pub fn hide_from_list(self) -> Self
Hide from list
Sourcepub fn max_length(self, len: usize) -> Self
pub fn max_length(self, len: usize) -> Self
Set max length
Trait Implementations§
Source§impl Clone for FieldDefinition
impl Clone for FieldDefinition
Source§fn clone(&self) -> FieldDefinition
fn clone(&self) -> FieldDefinition
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for FieldDefinition
impl Debug for FieldDefinition
Source§impl<'de> Deserialize<'de> for FieldDefinition
impl<'de> Deserialize<'de> for FieldDefinition
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
Auto Trait Implementations§
impl Freeze for FieldDefinition
impl RefUnwindSafe for FieldDefinition
impl Send for FieldDefinition
impl Sync for FieldDefinition
impl Unpin for FieldDefinition
impl UnwindSafe for FieldDefinition
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