Skip to main content

Field

Struct Field 

Source
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

Source

pub fn text<M, T>(lens: impl Into<Path<M, T>>) -> TextField
where M: Model, T: FormScalar + IntoExpr<T> + 'static,

Binds any FormScalar column, storing the type’s own spelling and probing uniqueness through the lens.

Source

pub fn choice<M, T>(lens: impl Into<Path<M, T>>) -> ChoiceField
where M: Model,

A choice field over any column, with options from options or relationship.

Source

pub fn file<M>(lens: impl Into<Path<M, String>>) -> FileField
where M: Model,

A file field over a String column holding the uploaded path, rendering no value attribute.

Source

pub fn toggle<M>(lens: impl Into<Path<M, bool>>) -> CustomField
where M: Model,

A checkbox over a bool column that submits false when unchecked.

Source

pub fn custom<M, T>( lens: impl Into<Path<M, T>>, control: impl Control + 'static, ) -> CustomField
where M: Model, T: FormScalar,

A field over any FormScalar column, rendered by an app’s Control.

Source

pub fn name(&self) -> &str

Trait Implementations§

Source§

impl Debug for Field

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl From<ChoiceField> for Field

Source§

fn from(builder: ChoiceField) -> Field

Converts to this type from the input type.
Source§

impl From<CustomField> for Field

Source§

fn from(builder: CustomField) -> Field

Converts to this type from the input type.
Source§

impl From<FileField> for Field

Source§

fn from(builder: FileField) -> Field

Converts to this type from the input type.
Source§

impl From<TextField> for Field

Source§

fn from(builder: TextField) -> Field

Converts to this type from the input type.
Source§

impl IntoSchema for Field

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> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self> ⓘ

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self> ⓘ

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more