pub struct FormField {
pub name: String,
pub label: Text,
pub field_type: String,
pub options: Value,
pub rules: Vec<Rule>,
pub translatable: bool,
}Expand description
One editable field: the column, its label, its field-type key (resolved through the field-type registry), typed options for that type, the validation rules it carries, and whether it holds translatable content. A serde descriptor, so it is authorable as data (later YAML) as well as by builder.
Fields§
§name: String§label: TextThe field’s label, localized at render. Serde stays a plain string.
field_type: StringThe field-type registry key (text, textarea, or a plugin’s
vendor.name), resolved to behaviour at render time (see crate::field).
options: ValuePer-type options, typed by the field type. Absent (null) for scalar types.
rules: Vec<Rule>Validation rules run on submit (see laterite_core::validation).
translatable: boolMarks a field whose value is translatable content. A reserved seam: the framework stores the value verbatim; a content-translation plugin reads the flag to manage per-locale values.
Implementations§
Source§impl FormField
impl FormField
Sourcepub fn of(name: &str, label: impl Into<Text>, field_type: &str) -> Self
pub fn of(name: &str, label: impl Into<Text>, field_type: &str) -> Self
A field of a registered type by key.
pub fn text(name: &str, label: impl Into<Text>) -> Self
pub fn textarea(name: &str, label: impl Into<Text>) -> Self
Sourcepub fn reference(name: &str, label: impl Into<Text>, source: &str) -> Self
pub fn reference(name: &str, label: impl Into<Text>, source: &str) -> Self
A reference field: a picker over a registered picker source (a vendor.name
key), which the field searches and resolves against. Builds the source
option so a descriptor needs no raw JSON.
Sourcepub fn options(self, options: Value) -> Self
pub fn options(self, options: Value) -> Self
Sets the field type’s typed options (the type validates them at render).
Sourcepub fn required_on(self, mode: Mode) -> Self
pub fn required_on(self, mode: Mode) -> Self
Requires a non-empty value in one mode only (for example a password set on create but left unchanged on edit).
Sourcepub fn unique(self) -> Self
pub fn unique(self) -> Self
Requires the value to be unique in this field’s column (a DB probe that ignores the edited row on update).
Sourcepub fn max_length(self, n: usize) -> Self
pub fn max_length(self, n: usize) -> Self
Caps the value’s length.
Sourcepub fn min_length(self, n: usize) -> Self
pub fn min_length(self, n: usize) -> Self
Requires at least n characters when the value is non-empty.
Sourcepub fn translatable(self) -> Self
pub fn translatable(self) -> Self
Marks this field as translatable content (see FormField::translatable).
Trait Implementations§
Source§impl<'de> Deserialize<'de> for FormField
impl<'de> Deserialize<'de> for FormField
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for FormField
impl RefUnwindSafe for FormField
impl Send for FormField
impl Sync for FormField
impl Unpin for FormField
impl UnsafeUnpin for FormField
impl UnwindSafe for FormField
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more