Having a page with form and action button to save
Hello Guys,
I'm trying to made a page,
with a form inside, for now a simple form, But it doesn't draw the button for saving .
So i've try to implement button by using
Forms\Components\Actions::make([
Forms\Components\Actions\Action::make('SaveCompanyName')
->color('primary')
->action(function (Forms\Set $set, $state) {
return $this->saveCompany();
})
])
but if i do that it will won't resprect the validation of the form.
so how can i do this ?
13 Replies
Why don't you just use a normal form with a submit button? π€
what do you mean by "normal" form ?
Just a form and a submit button as in the form-builder docs. Not sure where you found that SaveAction
my form is pretty "normal" according to me
public function form(Form $form): Form
{
return $form
->schema([
TextInput::make('title')->required(),
TextInput::make('slug'),
RichEditor::make('content'),
]);
}
and from the blade file
<x-filament-panels::page>
{{ $this->form }}
</x-filament-panels::page>
if i do the code above, there is no save button
because you didn't add one to your view. π
Ok thanks, and there is any way to have 2 forms on one page, on both diffrent panel ?
Not sure what you mean by different panels, but multiple forms is surely possible: https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component#using-multiple-forms
Btw i found a way
Untitled - Pastebin
Pastebin.pl is a website where you can store code/text online for a set period of time and share to anybody on earth
i used the function validate from livewire
Ok it doesn't take the valiation from the form itself, but at least it validate and display the correct error message in case of issue
there one still on small issue, is i put the color primary but thoses button do not respect the right primary color, and fallback to default primary
you can just use either two forms on one component as described in the docs, or use two components and put them on the same page (like breezy does)