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(lens!(User.name)).placeholder("Ada Lovelace"); // TextField
Field::text(lens!(User.email)).email().unique();
Field::text(lens!(User.age)); // typed: an `i64` column
Field::text(lens!(Post.body)).multiline(6);
Field::choice(lens!(Post.status)).options(Status::options()); // ChoiceField
Field::choice(lens!(Post.author_id)).relationship::<AuthorResource>();
Field::file(lens!(Doc.path)); // FileField
Field::toggle(lens!(Post.featured)); // CustomFieldtablo_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.
Sourcepub fn repeater<M, T>(lens: impl Into<Path<M, List<T>>>) -> RepeaterFieldwhere
M: Model,
T: RepeaterItem,
pub fn repeater<M, T>(lens: impl Into<Path<M, List<T>>>) -> RepeaterFieldwhere
M: Model,
T: RepeaterItem,
A row of T’s controls per item of a #[document] list of T, which the browser adds,
removes and moves: a record form’s #[form(repeat)] control.
Each row posts its item’s keys under {key}.{row}.. A resource’s form and an action’s
input fold them into key before reading the submission, and a page handling its own post
folds it with Schema::fold_repeaters; the items then
read with parse_items.
Sourcepub fn text_input<T: FormScalar>(name: impl Into<String>) -> TextField
pub fn text_input<T: FormScalar>(name: impl Into<String>) -> TextField
A text field posting name, a key no column binds: an ActionInput
field. T picks the input type, as a column’s type does for Field::text.
Sourcepub fn choice_input(name: impl Into<String>) -> ChoiceField
pub fn choice_input(name: impl Into<String>) -> ChoiceField
A choice field posting name, a key no column binds, with options from
options.
Sourcepub fn toggle_input(name: impl Into<String>) -> CustomField
pub fn toggle_input(name: impl Into<String>) -> CustomField
A checkbox posting name, a key no column binds, that submits false when unchecked.