pub struct FieldConditions { /* private fields */ }Expand description
The conditions of a form’s fields, by field name, and the fields that are live. Each method takes the field’s name and returns the conditions, so they chain.
As in Filament, a field has one hidden condition and one visible condition, and shows
only when its hidden condition fails and its visible condition holds. A later
hidden or hidden_on for the same field replaces the
earlier one, and so does a later visible or
visible_on. A field with no condition always shows.
Implementations§
Source§impl FieldConditions
impl FieldConditions
Sourcepub fn visible(
self,
field: impl Into<String>,
rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static,
) -> Self
pub fn visible( self, field: impl Into<String>, rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static, ) -> Self
Shows field only when rule holds, as Filament’s ->visible(fn () => ...).
Hides field when rule holds, as Filament’s ->hidden(fn () => ...).
Sourcepub fn visible_on(
self,
field: impl Into<String>,
operations: &[Operation],
) -> Self
pub fn visible_on( self, field: impl Into<String>, operations: &[Operation], ) -> Self
Shows field only on the forms of operations, as Filament’s ->visibleOn('edit').
Hides field on the forms of operations, as Filament’s ->hiddenOn('edit').
Sourcepub fn live(self, field: impl Into<String>) -> Self
pub fn live(self, field: impl Into<String>) -> Self
Makes field live, as Filament’s ->live(): when its value changes in the browser,
the form’s fields are shown again for the new value, so a field whose condition reads
it with FormContext::get appears or disappears. The browser sends the change when
the input fires change: at once for a select, a checkbox or a radio, and when a text
input loses focus.
Sourcepub fn is_shown(&self, field: &str, form: &FormContext<'_>) -> bool
pub fn is_shown(&self, field: &str, form: &FormContext<'_>) -> bool
Whether field shows in form: its hidden condition, if any, fails and its
visible condition, if any, holds.
The names of the fields that are hidden on the form for operation, editing
record, for user, whose fields hold values.
A condition that reads a hidden field gets the field’s stored value, not the one in
values, so a request cannot show a field by sending a value for a field it may not
see. The conditions run again until the hidden fields settle.
Trait Implementations§
Source§impl Clone for FieldConditions
impl Clone for FieldConditions
Source§impl Debug for FieldConditions
impl Debug for FieldConditions
Auto Trait Implementations§
impl !RefUnwindSafe for FieldConditions
impl !UnwindSafe for FieldConditions
impl Forget for FieldConditions
impl Freeze for FieldConditions
impl Move for FieldConditions
impl Send for FieldConditions
impl Sync for FieldConditions
impl Unpin for FieldConditions
impl UnsafeUnpin for FieldConditions
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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