pub struct SchemaForm { /* private fields */ }Expand description
A form built from a schema.
It is a view rather than a builder because the fields it composes —
TextInput, NumberInput, Select, Combobox, TagInput —
each own a caret, an open menu, or a selection that has to survive a frame.
Implementations§
Source§impl SchemaForm
impl SchemaForm
pub fn new( ident: impl Into<Ident>, schema: Schema, window: &mut Window, cx: &mut Context<'_, Self>, ) -> Self
Sourcepub fn set_error(
&mut self,
path: impl Into<SharedString>,
message: impl Into<SharedString>,
cx: &mut Context<'_, Self>,
)
pub fn set_error( &mut self, path: impl Into<SharedString>, message: impl Into<SharedString>, cx: &mut Context<'_, Self>, )
Shows an error the host returned, next to the field it is about.
Sourcepub fn clear_host_errors(&mut self, cx: &mut Context<'_, Self>)
pub fn clear_host_errors(&mut self, cx: &mut Context<'_, Self>)
Withdraws every error the host reported. What the form worked out for itself is untouched, because the host did not put it there.
Sourcepub fn validate(&mut self, cx: &mut Context<'_, Self>) -> bool
pub fn validate(&mut self, cx: &mut Context<'_, Self>) -> bool
Marks every required field nobody filled in, and reports whether the form is answerable at all.
A form holding a field it cannot draw is never answerable, whatever is typed into the rest of it. Neither is one holding a number outside the range the schema gave it: the control already draws that as wrong, and a form that called it answerable anyway would be contradicting what is on screen.
Sourcepub fn values(&self, cx: &App) -> Vec<(SharedString, FieldValue)>
pub fn values(&self, cx: &App) -> Vec<(SharedString, FieldValue)>
Every field and what it holds, including the ones the form could not draw. A caller that builds a call from this cannot lose a field without seeing it.
Sourcepub fn unrenderable(&self) -> &[UnrenderableField]
pub fn unrenderable(&self) -> &[UnrenderableField]
The fields that have to be filled in somewhere else.
Sourcepub fn has_unrenderable_required(&self) -> bool
pub fn has_unrenderable_required(&self) -> bool
Whether any field the form could not draw is one the call requires.
pub fn set_disabled(&mut self, disabled: bool, cx: &mut Context<'_, Self>)
Trait Implementations§
Source§impl Debug for SchemaForm
impl Debug for SchemaForm
Source§impl Disableable for SchemaForm
impl Disableable for SchemaForm
impl EventEmitter<SchemaFormEvent> for SchemaForm
Source§impl Render for SchemaForm
impl Render for SchemaForm
Auto Trait Implementations§
impl !RefUnwindSafe for SchemaForm
impl !Send for SchemaForm
impl !Sync for SchemaForm
impl !UnwindSafe for SchemaForm
impl Freeze for SchemaForm
impl Unpin for SchemaForm
impl UnsafeUnpin for SchemaForm
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> 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