pub struct FormWidget { /* private fields */ }Expand description
A dashboard widget with a short form that creates a record of a resource, as a Filament
custom widget with a form: WordPress’s “Quick Draft” (a title, the content and “Save
Draft”). Pass it to Ignite::form_widget. The form shows the resource’s fields (all of
them, or the ones fields names, in that order) and posts to the
resource’s create route with the CSRF token, so the resource’s validation, policy and
create_for run as for its own form; the panel then comes back to the dashboard with the
flash message. A form that does not validate shows the resource’s create form with its
errors. The widget shows only to a user who may create a record of the resource.
FormWidget::make("Quick Draft", "posts")
.fields(["title", "content"])
.hidden("status", "draft")
.submit_label("Save Draft")Implementations§
Source§impl FormWidget
impl FormWidget
Sourcepub fn make(title: impl Into<String>, slug: impl Into<String>) -> Self
pub fn make(title: impl Into<String>, slug: impl Into<String>) -> Self
A widget titled title whose form creates a record of the resource at slug.
Sourcepub fn fields<I, S>(self, names: I) -> Self
pub fn fields<I, S>(self, names: I) -> Self
The resource’s fields the form shows, in order. The default is every field.
A value the form sends without showing it, such as status = draft. The resource’s
validation reads it as any other field’s value.
Sourcepub fn submit_label(self, label: impl Into<String>) -> Self
pub fn submit_label(self, label: impl Into<String>) -> Self
The button’s text. The default is “Save”.
Sourcepub fn get_resource(&self) -> &str
pub fn get_resource(&self) -> &str
The slug of the resource the form creates a record of.
Sourcepub fn get_fields(&self) -> &[String]
pub fn get_fields(&self) -> &[String]
The names of the fields the form shows; empty for every field.
The values the form sends without showing them.
Sourcepub fn get_submit_label(&self) -> &str
pub fn get_submit_label(&self) -> &str
The button’s text.
Trait Implementations§
Source§impl Clone for FormWidget
impl Clone for FormWidget
Source§impl Debug for FormWidget
impl Debug for FormWidget
impl Eq for FormWidget
Source§impl PartialEq for FormWidget
impl PartialEq for FormWidget
impl StructuralPartialEq for FormWidget
Auto Trait Implementations§
impl Forget for FormWidget
impl Freeze for FormWidgetwhere
*const u8 is !null: Freeze,
PhantomData<u8>: Freeze,
PhantomData<String>: Freeze,
PhantomData<(String, String)>: Freeze,
impl Move for FormWidget
impl RefUnwindSafe for FormWidget
impl Send for FormWidgetwhere
RawVecInner: Send,
impl Sync for FormWidgetwhere
RawVecInner: Sync,
impl Unpin for FormWidget
impl UnsafeUnpin for FormWidgetwhere
*const u8 is !null: UnsafeUnpin,
PhantomData<u8>: UnsafeUnpin,
PhantomData<String>: UnsafeUnpin,
PhantomData<(String, String)>: UnsafeUnpin,
impl UnwindSafe for FormWidgetwhere
RawVecInner: UnwindSafe,
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<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
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