pub struct MultiValueField {
pub name: String,
pub label: Option<String>,
pub required: bool,
pub help_text: Option<String>,
pub widget: Widget,
pub initial: Option<Value>,
pub fields: Vec<Box<dyn FormField>>,
pub require_all_fields: bool,
}Expand description
MultiValueField combines multiple fields into one
Fields§
§name: String§label: Option<String>§required: bool§help_text: Option<String>§widget: Widget§initial: Option<Value>§fields: Vec<Box<dyn FormField>>§require_all_fields: boolImplementations§
Source§impl MultiValueField
impl MultiValueField
Sourcepub fn new(name: String, fields: Vec<Box<dyn FormField>>) -> Self
pub fn new(name: String, fields: Vec<Box<dyn FormField>>) -> Self
Create a new MultiValueField
§Examples
use reinhardt_forms::fields::MultiValueField;
use reinhardt_forms::fields::{CharField, IntegerField};
use reinhardt_forms::FormField;
use serde_json::json;
let fields: Vec<Box<dyn FormField>> = vec![
Box::new(CharField::new("name".to_string())),
Box::new(IntegerField::new("age".to_string())),
];
let field = MultiValueField::new("person".to_string(), fields);
let result = field.clean(Some(&json!(["John Doe", 30])));
assert!(result.is_ok());pub fn compress(&self, values: Vec<Value>) -> FieldResult<Value>
Trait Implementations§
Source§impl FormField for MultiValueField
impl FormField for MultiValueField
fn name(&self) -> &str
fn label(&self) -> Option<&str>
fn required(&self) -> bool
fn help_text(&self) -> Option<&str>
fn widget(&self) -> &Widget
fn initial(&self) -> Option<&Value>
fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
Auto Trait Implementations§
impl Freeze for MultiValueField
impl !RefUnwindSafe for MultiValueField
impl Send for MultiValueField
impl Sync for MultiValueField
impl Unpin for MultiValueField
impl UnsafeUnpin for MultiValueField
impl !UnwindSafe for MultiValueField
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