pub struct FormSetFactory { /* private fields */ }Expand description
Factory for creating FormSets dynamically
This allows you to create FormSets with different configurations without defining them statically.
Implementations§
Source§impl FormSetFactory
impl FormSetFactory
Sourcepub fn new(prefix: String) -> Self
pub fn new(prefix: String) -> Self
Create a new FormSetFactory
§Examples
use reinhardt_forms::FormSetFactory;
let factory = FormSetFactory::new("form".to_string());
assert_eq!(factory.extra(), 1);Sourcepub fn with_extra(self, extra: usize) -> Self
pub fn with_extra(self, extra: usize) -> Self
Set extra forms count
§Examples
use reinhardt_forms::FormSetFactory;
let factory = FormSetFactory::new("form".to_string())
.with_extra(3);
assert_eq!(factory.extra(), 3);Sourcepub fn with_can_delete(self, can_delete: bool) -> Self
pub fn with_can_delete(self, can_delete: bool) -> Self
Enable deletion
§Examples
use reinhardt_forms::FormSetFactory;
let factory = FormSetFactory::new("form".to_string())
.with_can_delete(true);
assert!(factory.can_delete());Sourcepub fn with_can_order(self, can_order: bool) -> Self
pub fn with_can_order(self, can_order: bool) -> Self
Enable ordering
§Examples
use reinhardt_forms::FormSetFactory;
let factory = FormSetFactory::new("form".to_string())
.with_can_order(true);
assert!(factory.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::FormSetFactory;
let factory = FormSetFactory::new("form".to_string())
.with_max_num(Some(10));
assert_eq!(factory.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::FormSetFactory;
let factory = FormSetFactory::new("form".to_string())
.with_min_num(2);
assert_eq!(factory.min_num(), 2);Sourcepub fn can_delete(&self) -> bool
pub fn can_delete(&self) -> bool
Check if deletion is enabled
Sourcepub fn create(&self) -> FormSet
pub fn create(&self) -> FormSet
Create a FormSet from this factory
§Examples
use reinhardt_forms::{FormSetFactory, FormSet};
let factory = FormSetFactory::new("form".to_string())
.with_extra(3)
.with_can_delete(true);
let formset = factory.create();
assert_eq!(formset.prefix(), "form");
assert!(formset.can_delete());Sourcepub fn create_model_formset<T: FormModel>(&self) -> ModelFormSet<T>
pub fn create_model_formset<T: FormModel>(&self) -> ModelFormSet<T>
Auto Trait Implementations§
impl Freeze for FormSetFactory
impl RefUnwindSafe for FormSetFactory
impl Send for FormSetFactory
impl Sync for FormSetFactory
impl Unpin for FormSetFactory
impl UnsafeUnpin for FormSetFactory
impl UnwindSafe for FormSetFactory
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