Skip to main content

TextField

Struct TextField 

Source
pub struct TextField<F = ()>(/* private fields */);
Expand description

A text field: Field::text, or a record form’s text control (F is the form).

Implementations§

Source§

impl<F> TextField<F>

Source

pub fn label(self, label: impl Into<String>) -> Self

Source

pub fn name(&self) -> &str

Source

pub fn visible_when( self, watched: &impl Watched<F>, values: impl IntoIterator<Item = impl Into<String>>, ) -> Self

Shows the field only while watched posts one of values: an option’s value, or true for a checked toggle. A hidden field posts nothing, so an edit keeps its stored value and a create takes its blank answer; a field with no blank answer cannot be conditional.

let kind = Field::choice(Customer::fields().kind()).options(["person", "company"]);
let vat = Field::text(Customer::fields().vat_number()).visible_when(&kind, ["company"]);
Schema::new((kind, vat));
Source§

impl<F> TextField<F>

Source

pub fn custom(self, control: impl Control + 'static) -> CustomField<F>

Renders the field with an app’s Control instead, as Field::custom does: how a record form’s control takes a custom input. The field keeps its key and label; the replaced control’s own modifiers, such as email, unique or options, are dropped with it.

Source§

impl<F> TextField<F>

Source

pub fn choice(self) -> ChoiceField<F>

Renders the field as a choice instead, as Field::choice does, ready for options or relationship. Unlike #[form(relationship = ..)], it leaves the record form’s derived table and detail page as they are. The replaced control’s own modifiers are dropped with it.

Source§

impl<F> TextField<F>

Source

pub fn email(self) -> Self

Validate the value as an email address, and render type="email".

Source

pub fn password(self) -> Self

Render type="password": the browser masks the value, and a refused form renders the control empty rather than echoing the password back into the page.

Source

pub fn unique(self) -> Self

Probes a unique index before the write.

Source

pub fn placeholder(self, placeholder: impl Into<String>) -> Self

The control’s placeholder text.

Source

pub fn multiline(self, rows: u32) -> Self

Render a <textarea> of rows lines rather than a one-line input, for a column holding prose.

Trait Implementations§

Source§

impl<F> From<TextField<F>> for Field

Source§

fn from(builder: TextField<F>) -> Field

Converts to this type from the input type.
Source§

impl<F> IntoSchema<F> for TextField<F>

Source§

impl<F> Watched<F> for TextField<F>

Auto Trait Implementations§

§

impl<F = ()> !Freeze for TextField<F>

§

impl<F = ()> !RefUnwindSafe for TextField<F>

§

impl<F = ()> !UnwindSafe for TextField<F>

§

impl<F> Send for TextField<F>
where PhantomData<fn() -> F>: Send,

§

impl<F> Sync for TextField<F>
where PhantomData<fn() -> F>: Sync,

§

impl<F> Unpin for TextField<F>
where PhantomData<fn() -> F>: Unpin,

§

impl<F> UnsafeUnpin for TextField<F>
where PhantomData<fn() -> F>: UnsafeUnpin,

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