pub struct FormHandle { /* private fields */ }Expand description
A resource’s form, written through from code.
Runs what the form’s own submit runs, with no request in hand: the values
are validated against the form’s rules, shaped by its field types and saved
through its listeners and persister, so an importer or a sync writes exactly
what an operator could have typed, audited the same way. A screen reaches one
through crate::routes::RouteCtx::form.
Implementations§
Source§impl FormHandle
impl FormHandle
Sourcepub fn fields(&self) -> &[FormField]
pub fn fields(&self) -> &[FormField]
The fields the form declares, in order. data is keyed by their names.
Sourcepub async fn create(
&self,
data: HashMap<String, String>,
actor: &Actor,
) -> Result<i64, SaveError>
pub async fn create( &self, data: HashMap<String, String>, actor: &Actor, ) -> Result<i64, SaveError>
Validates data as a submission and saves a new record, returning its id.
data holds each field’s value under the field’s name, as the form’s
control submits it; a field left out is blank. Invalid carries the
per-field messages a refused submit would show.
Sourcepub async fn load(
&self,
id: i64,
) -> Result<Option<HashMap<String, String>>, SaveError>
pub async fn load( &self, id: i64, ) -> Result<Option<HashMap<String, String>>, SaveError>
The record id as the edit form shows it: each stored value back through
its field type, keyed by field name. None when no record has that id.
Lay a partial data over it before update to change
some fields and keep the rest.
Trait Implementations§
Auto Trait Implementations§
impl !RefUnwindSafe for FormHandle
impl !UnwindSafe for FormHandle
impl Freeze for FormHandle
impl Send for FormHandle
impl Sync for FormHandle
impl Unpin for FormHandle
impl UnsafeUnpin for FormHandle
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<A, B, T> HttpServerConnExec<A, B> for Twhere
B: Body,
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