pub trait FormScalar: Sized {
const INPUT_TYPE: &'static str = "text";
const STEP: Option<&'static str> = None;
const SORTABLE: bool = true;
// Required methods
fn parse_form(value: &str) -> Result<Self, Text>;
fn to_form(&self) -> String;
// Provided methods
fn input_value(stored: &str, zone: &TimeZone) -> String { ... }
fn form_value(posted: &str, zone: &TimeZone) -> String { ... }
fn to_label(&self) -> Text { ... }
fn color(&self) -> Option<Color> { ... }
fn icon(&self) -> Option<IconData> { ... }
fn order(&self, _other: &Self) -> Option<Ordering> { ... }
}Expand description
A type one form key reads and writes: String, every TypedValue type,
every enum deriving Options, and an Option of any of them.
The value the parse sees is trimmed and non-empty; an empty submission is the record-form field’s blank answer instead, and a field with none is required.
A text field binds a path of any FormScalar type
(Field::text), and the form derives read and write
every field that is not #[form(embed)] through it.
Provided Associated Constants§
Sourceconst INPUT_TYPE: &'static str = "text"
const INPUT_TYPE: &'static str = "text"
The type attribute of the text control that edits it.
Sourceconst STEP: Option<&'static str> = None
const STEP: Option<&'static str> = None
The control’s step attribute, when its input type takes one.
Sourceconst SORTABLE: bool = true
const SORTABLE: bool = true
Whether the database orders the stored column as the values order: a TypedValue’s
SORTABLE, and true for any other type.
Required Methods§
Sourcefn parse_form(value: &str) -> Result<Self, Text>
fn parse_form(value: &str) -> Result<Self, Text>
Parse a trimmed, non-empty submission, or return the error message.
Sourcefn to_form(&self) -> String
fn to_form(&self) -> String
The form spelling of a stored value: a TypedValue’s
form_spelling.
Provided Methods§
Sourcefn input_value(stored: &str, zone: &TimeZone) -> String
fn input_value(stored: &str, zone: &TimeZone) -> String
The control’s value for a stored value’s form spelling, shown in the request’s time zone
zone: a TypedValue’s input_value, and the spelling
itself for any other type.
Sourcefn form_value(posted: &str, zone: &TimeZone) -> String
fn form_value(posted: &str, zone: &TimeZone) -> String
The form spelling of what the control posted, read in the request’s time zone zone: a
TypedValue’s form_value, and the posted text itself for
any other type.
Sourcefn to_label(&self) -> Text
fn to_label(&self) -> Text
What a column cell and a group header read: the form spelling, or an
Options enum’s label.
Sourcefn color(&self) -> Option<Color>
fn color(&self) -> Option<Color>
The color a badge shows the value in: an Options enum’s #[option(color = "…")], and
None for any other type.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".