pub struct ChoiceField {
pub name: String,
pub label: Option<String>,
pub required: bool,
pub help_text: Option<String>,
pub widget: Widget,
pub initial: Option<Value>,
pub choices: Vec<(String, String)>,
}Expand description
ChoiceField for selecting from predefined choices
Fields§
§name: StringThe field name used as the form data key.
label: Option<String>Optional human-readable label for display.
required: boolWhether a selection is required.
help_text: Option<String>Optional help text displayed alongside the field.
widget: WidgetThe widget type used for rendering this field.
initial: Option<Value>Optional initial (default) value for the field.
choices: Vec<(String, String)>Available choices as (value, display_label) pairs.
Implementations§
Source§impl ChoiceField
impl ChoiceField
Sourcepub fn new(name: String, choices: Vec<(String, String)>) -> Self
pub fn new(name: String, choices: Vec<(String, String)>) -> Self
Create a new ChoiceField
§Examples
use reinhardt_forms::fields::ChoiceField;
let choices = vec![("1".to_string(), "Option 1".to_string())];
let field = ChoiceField::new("choice".to_string(), choices);
assert_eq!(field.name, "choice");Trait Implementations§
Source§impl Clone for ChoiceField
impl Clone for ChoiceField
Source§fn clone(&self) -> ChoiceField
fn clone(&self) -> ChoiceField
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · 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 ChoiceField
impl Debug for ChoiceField
Source§impl FormField for ChoiceField
impl FormField for ChoiceField
Source§fn initial(&self) -> Option<&Value>
fn initial(&self) -> Option<&Value>
Returns the initial (default) value for this field, if any.
Source§fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
fn clean(&self, value: Option<&Value>) -> FieldResult<Value>
Validates and cleans the submitted value, returning the cleaned result.
Auto Trait Implementations§
impl Freeze for ChoiceField
impl RefUnwindSafe for ChoiceField
impl Send for ChoiceField
impl Sync for ChoiceField
impl Unpin for ChoiceField
impl UnsafeUnpin for ChoiceField
impl UnwindSafe for ChoiceField
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