pub struct ModelFormSetConfig {
pub form_config: ModelFormConfig,
pub can_delete: bool,
pub can_order: bool,
pub extra: usize,
pub max_num: Option<usize>,
pub min_num: usize,
}Expand description
Configuration for ModelFormSet
Fields§
§form_config: ModelFormConfigConfiguration for individual model forms
can_delete: boolAllow deletion of instances
can_order: boolAllow ordering of instances
extra: usizeNumber of extra forms to display
max_num: Option<usize>Maximum number of forms
min_num: usizeMinimum number of forms
Implementations§
Source§impl ModelFormSetConfig
impl ModelFormSetConfig
Sourcepub fn new() -> Self
pub fn new() -> Self
Create a new ModelFormSetConfig
§Examples
use reinhardt_forms::ModelFormSetConfig;
let config = ModelFormSetConfig::new();
assert_eq!(config.extra, 1);
assert!(!config.can_delete);Sourcepub fn with_extra(self, extra: usize) -> Self
pub fn with_extra(self, extra: usize) -> Self
Set the number of extra forms
§Examples
use reinhardt_forms::ModelFormSetConfig;
let config = ModelFormSetConfig::new().with_extra(3);
assert_eq!(config.extra, 3);Sourcepub fn with_can_delete(self, can_delete: bool) -> Self
pub fn with_can_delete(self, can_delete: bool) -> Self
Enable or disable deletion
§Examples
use reinhardt_forms::ModelFormSetConfig;
let config = ModelFormSetConfig::new().with_can_delete(true);
assert!(config.can_delete);Sourcepub fn with_can_order(self, can_order: bool) -> Self
pub fn with_can_order(self, can_order: bool) -> Self
Enable or disable ordering
§Examples
use reinhardt_forms::ModelFormSetConfig;
let config = ModelFormSetConfig::new().with_can_order(true);
assert!(config.can_order);Sourcepub fn with_max_num(self, max_num: Option<usize>) -> Self
pub fn with_max_num(self, max_num: Option<usize>) -> Self
Set maximum number of forms
§Examples
use reinhardt_forms::ModelFormSetConfig;
let config = ModelFormSetConfig::new().with_max_num(Some(10));
assert_eq!(config.max_num, Some(10));Sourcepub fn with_min_num(self, min_num: usize) -> Self
pub fn with_min_num(self, min_num: usize) -> Self
Set minimum number of forms
§Examples
use reinhardt_forms::ModelFormSetConfig;
let config = ModelFormSetConfig::new().with_min_num(2);
assert_eq!(config.min_num, 2);Sourcepub fn with_form_config(self, form_config: ModelFormConfig) -> Self
pub fn with_form_config(self, form_config: ModelFormConfig) -> Self
Set the form configuration
§Examples
use reinhardt_forms::{ModelFormSetConfig, ModelFormConfig};
let form_config = ModelFormConfig::new()
.fields(vec!["name".to_string(), "email".to_string()]);
let config = ModelFormSetConfig::new().with_form_config(form_config);
assert!(config.form_config.fields.is_some());Trait Implementations§
Source§impl Clone for ModelFormSetConfig
impl Clone for ModelFormSetConfig
Source§fn clone(&self) -> ModelFormSetConfig
fn clone(&self) -> ModelFormSetConfig
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 ModelFormSetConfig
impl Debug for ModelFormSetConfig
Auto Trait Implementations§
impl Freeze for ModelFormSetConfig
impl RefUnwindSafe for ModelFormSetConfig
impl Send for ModelFormSetConfig
impl Sync for ModelFormSetConfig
impl Unpin for ModelFormSetConfig
impl UnsafeUnpin for ModelFormSetConfig
impl UnwindSafe for ModelFormSetConfig
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