pub struct Field { /* private fields */ }Expand description
One form field binding a lens to the control editing it, offering only that control’s modifiers so a modifier on the wrong control does not compile.
Field::text(User::fields().name()).placeholder("Ada Lovelace"); // TextField
Field::text(User::fields().email()).email().unique();
Field::text(User::fields().age()); // typed: an `i64` column
Field::text(Post::fields().body()).multiline(6);
Field::choice(Post::fields().status()).options(Status::options()); // ChoiceField
Field::choice(Post::fields().author_id())
.relationship::<AuthorResource>(|a: &Author| a.name.clone());
Field::file(Doc::fields().path()); // FileField
Field::toggle(Post::fields().featured()); // CustomFieldⓘ
tablo_core::Field::text(User::fields().name()).options(["admin", "member"]);Implementations§
Source§impl Field
impl Field
Sourcepub fn text<M, T>(lens: impl Into<Path<M, T>>) -> TextField
pub fn text<M, T>(lens: impl Into<Path<M, T>>) -> TextField
Binds any FormScalar column, storing the type’s own spelling and probing uniqueness
through the lens.
Sourcepub fn choice<M, T>(lens: impl Into<Path<M, T>>) -> ChoiceFieldwhere
M: Model,
pub fn choice<M, T>(lens: impl Into<Path<M, T>>) -> ChoiceFieldwhere
M: Model,
A choice field over any column, with options from options or
relationship.
Sourcepub fn file<M>(lens: impl Into<Path<M, String>>) -> FileFieldwhere
M: Model,
pub fn file<M>(lens: impl Into<Path<M, String>>) -> FileFieldwhere
M: Model,
A file field over a String column holding the uploaded path, rendering no value
attribute.
Sourcepub fn toggle<M>(lens: impl Into<Path<M, bool>>) -> CustomFieldwhere
M: Model,
pub fn toggle<M>(lens: impl Into<Path<M, bool>>) -> CustomFieldwhere
M: Model,
A checkbox over a bool column that submits false when unchecked.
Sourcepub fn custom<M, T>(
lens: impl Into<Path<M, T>>,
control: impl Control + 'static,
) -> CustomFieldwhere
M: Model,
T: FormScalar,
pub fn custom<M, T>(
lens: impl Into<Path<M, T>>,
control: impl Control + 'static,
) -> CustomFieldwhere
M: Model,
T: FormScalar,
A field over any FormScalar column, rendered by an app’s Control.
pub fn name(&self) -> &str
Trait Implementations§
Source§impl From<ChoiceField> for Field
impl From<ChoiceField> for Field
Source§fn from(builder: ChoiceField) -> Field
fn from(builder: ChoiceField) -> Field
Converts to this type from the input type.
Source§impl From<CustomField> for Field
impl From<CustomField> for Field
Source§fn from(builder: CustomField) -> Field
fn from(builder: CustomField) -> Field
Converts to this type from the input type.
Source§impl IntoSchema for Field
impl IntoSchema for Field
fn into_schema(self) -> Schema
Auto Trait Implementations§
impl !RefUnwindSafe for Field
impl !UnwindSafe for Field
impl Freeze for Field
impl Send for Field
impl Sync for Field
impl Unpin for Field
impl UnsafeUnpin for Field
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