pub struct ModelFormSet<T: FormModel> { /* private fields */ }Expand description
A formset for managing multiple model instances
Implementations§
Source§impl<T: FormModel> ModelFormSet<T>
impl<T: FormModel> ModelFormSet<T>
Sourcepub fn new(
prefix: String,
instances: Vec<T>,
config: ModelFormSetConfig,
) -> Self
pub fn new( prefix: String, instances: Vec<T>, config: ModelFormSetConfig, ) -> Self
Create a new ModelFormSet with instances
§Examples
ⓘ
use reinhardt_forms::{ModelFormSet, ModelFormSetConfig};
let config = ModelFormSetConfig::new();
let instances = vec![]; // Empty list of model instances
let formset = ModelFormSet::<MyModel>::new("formset".to_string(), instances, config);
assert_eq!(formset.prefix(), "formset");Sourcepub fn empty(prefix: String, config: ModelFormSetConfig) -> Self
pub fn empty(prefix: String, config: ModelFormSetConfig) -> Self
pub fn prefix(&self) -> &str
pub fn instances(&self) -> Vec<&T>
pub fn form_count(&self) -> usize
pub fn total_form_count(&self) -> usize
pub fn errors(&self) -> Vec<String>
Sourcepub fn management_form_data(&self) -> HashMap<String, String>
pub fn management_form_data(&self) -> HashMap<String, String>
Get management form data for HTML rendering
§Examples
ⓘ
use reinhardt_forms::{ModelFormSet, ModelFormSetConfig};
let config = ModelFormSetConfig::new().with_extra(2);
let formset = ModelFormSet::<MyModel>::empty("article".to_string(), config);
let mgmt_data = formset.management_form_data();
assert!(mgmt_data.contains_key("article-TOTAL_FORMS"));
assert_eq!(mgmt_data.get("article-TOTAL_FORMS"), Some(&"2".to_string()));Auto Trait Implementations§
impl<T> Freeze for ModelFormSet<T>
impl<T> !RefUnwindSafe for ModelFormSet<T>
impl<T> Send for ModelFormSet<T>
impl<T> Sync for ModelFormSet<T>
impl<T> Unpin for ModelFormSet<T>where
T: Unpin,
impl<T> UnsafeUnpin for ModelFormSet<T>
impl<T> !UnwindSafe for ModelFormSet<T>
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