pub struct RepeaterSettings { /* private fields */ }Expand description
The settings of a repeater or flexible content field, as Filament’s Repeater and
Builder methods. The default allows any number of rows, adds, deletes and moves rows,
and labels each row by its number.
As Filament’s addable(fn), deletable(fn) and reorderable(fn), each of the three can
instead be decided per record by a rule (addable_when and the
others). The rule runs on the form’s FormContext (the record and the signed-in user) and
replaces the flat setting. Repeaters::resolved turns the rules into flat settings for
one form.
Implementations§
Source§impl RepeaterSettings
impl RepeaterSettings
Sourcepub fn min_items(self, count: usize) -> Self
pub fn min_items(self, count: usize) -> Self
The fewest rows the field saves with, as Filament’s minItems(). Fewer is refused with
“
Sourcepub fn max_items(self, count: usize) -> Self
pub fn max_items(self, count: usize) -> Self
The most rows the field takes, as Filament’s maxItems(). The add button hides at the
limit, and more is refused with “
Sourcepub fn item_label(self, field: impl Into<String>) -> Self
pub fn item_label(self, field: impl Into<String>) -> Self
Labels each row by the value of its sub-field field, as Filament’s
itemLabel(fn (array $state) => $state['name']) and ACF’s “collapsed” setting. A row
whose value is blank shows its number.
Sourcepub fn add_action_label(self, label: impl Into<String>) -> Self
pub fn add_action_label(self, label: impl Into<String>) -> Self
The label of the add button, as Filament’s addActionLabel(). The default is “Add to
Sourcepub fn addable(self, addable: bool) -> Self
pub fn addable(self, addable: bool) -> Self
Whether rows can be added, as Filament’s addable(). The default is true.
Sourcepub fn deletable(self, deletable: bool) -> Self
pub fn deletable(self, deletable: bool) -> Self
Whether rows can be deleted, as Filament’s deletable(). The default is true.
Sourcepub fn reorderable(self, reorderable: bool) -> Self
pub fn reorderable(self, reorderable: bool) -> Self
Whether rows can be moved up and down, as Filament’s reorderableWithButtons(). The
default is true; false is Filament’s reorderable(false).
Sourcepub fn addable_when(
self,
rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static,
) -> Self
pub fn addable_when( self, rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static, ) -> Self
Whether rows can be added for this record, as Filament’s addable(fn): rule runs on
the form’s context and replaces addable.
Sourcepub fn deletable_when(
self,
rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static,
) -> Self
pub fn deletable_when( self, rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static, ) -> Self
Whether rows can be deleted for this record, as Filament’s deletable(fn): rule runs
on the form’s context and replaces deletable.
Sourcepub fn reorderable_when(
self,
rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static,
) -> Self
pub fn reorderable_when( self, rule: impl Fn(&FormContext<'_>) -> bool + Send + Sync + 'static, ) -> Self
Whether rows can be moved up and down for this record, as Filament’s reorderable(fn):
rule runs on the form’s context and replaces reorderable.
Sourcepub fn resolved(&self, form: &FormContext<'_>) -> RepeaterSettings
pub fn resolved(&self, form: &FormContext<'_>) -> RepeaterSettings
These settings for one form: each rule set with addable_when,
deletable_when or reorderable_when
decides its flag for form, and the flat setting stays where no rule is set.
Sourcepub fn get_min_items(&self) -> Option<usize>
pub fn get_min_items(&self) -> Option<usize>
The fewest rows, if set.
Sourcepub fn get_max_items(&self) -> Option<usize>
pub fn get_max_items(&self) -> Option<usize>
The most rows, if set.
Sourcepub fn get_item_label(&self) -> Option<&str>
pub fn get_item_label(&self) -> Option<&str>
The sub-field whose value labels each row, if set.
Sourcepub fn get_add_action_label(&self) -> Option<&str>
pub fn get_add_action_label(&self) -> Option<&str>
The label of the add button, if set.
Sourcepub fn is_addable(&self) -> bool
pub fn is_addable(&self) -> bool
Whether rows can be added.
Sourcepub fn is_deletable(&self) -> bool
pub fn is_deletable(&self) -> bool
Whether rows can be deleted.
Sourcepub fn is_reorderable(&self) -> bool
pub fn is_reorderable(&self) -> bool
Whether rows can be moved.
Trait Implementations§
Source§impl Clone for RepeaterSettings
impl Clone for RepeaterSettings
Source§impl Debug for RepeaterSettings
impl Debug for RepeaterSettings
Auto Trait Implementations§
impl !RefUnwindSafe for RepeaterSettings
impl !UnwindSafe for RepeaterSettings
impl Forget for RepeaterSettings
impl Freeze for RepeaterSettingswhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
*const ArcInner<dyn Fn(&FormContext<'_>) -> bool + Send + Sync> is !null: Freeze,
PhantomData<ArcInner<dyn Fn(&FormContext<'_>) -> bool + Send + Sync>>: Freeze,
impl Move for RepeaterSettings
impl Send for RepeaterSettings
impl Sync for RepeaterSettings
impl Unpin for RepeaterSettings
impl UnsafeUnpin for RepeaterSettingswhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
*const ArcInner<dyn Fn(&FormContext<'_>) -> bool + Send + Sync> is !null: UnsafeUnpin,
PhantomData<ArcInner<dyn Fn(&FormContext<'_>) -> bool + Send + Sync>>: UnsafeUnpin,
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