Multiple forms on custom page
Hello, is there any way I can add multiple forms to a custom page? I the
getFormSchema()
method in my component that is already creating up a form but I need to add one more form for a different action.17 Replies
yes it describes the process in the Getting Started page of the form builder docs
with
getForms()
Thank you
Is there any way i can display actions in a different position from the top right corner?
but how to display it? I see an example that say that you can override the
getFormSchema()
method with a custom method with a name, but if in the view I do {{$this->authorForm}}
I get property not found on componentsend the code you use in getForms()
Oh I see, thank you very much.
Any answer to this? I see I can create custom actions but It's going to be displayed in the top right corner by default, but I would like to display it in custom position.
I have followed the docs and your advices but I can-t get it to work on a custom view page.
send the code you use in getForms()
Here's my
getForms()
: protected function getForms(): array
{
return [
'chatForm' => $this->makeForm()
->schema($this->getChatFormSchema())
->model($this->ticket),
"updateManagerForm"=>$this->makeForm()
->schema($this->getChatFormSchema())
->model($this->ticket),
];
}
Unsure if I have to pass $this->ticket or $this->recordso where is authorForm
I just made a test with the Example of the docs, but now I'm using actual names
a form isnt gonna turn into an action, its just gonna be rendered on the page like another form
actions are currently limited to the header only unless you write custom modal html
That is what I'm trying to achieve, the action is a separate question.
i don’t understand the question then
Ok, I imagined so for the actions.
From title, how to display multiple forms on custom pages
Above you pointed me that I could find example in the docs, now I'm following the example and your advices to render multiple forms on a page
From what I see in the example in the docs, It should work now but I keep getting errors.
This is what I have done so far, can you please help me to understand where I'm wrong?
Here's my full class
You sent the code to add to the view already
{{ $this->formName }}
then you define formName in the getForms() pass a schema()
exactly like the example in the docs.
Ok, it seems to me I have done so in my code, but whenever i try to run it I get this error:
Typed property App\Filament\Resources\TicketResource\Pages\ViewTicket::$ticket must not be accessed before initialization
Which is being thrown at :
'chatForm' => $this->makeForm()
->schema($this->getChatFormSchema())
->model($this->ticket),
So i tried to change to $this->record but i get:
Filament\Resources\Pages\ViewRecord::getRecord(): Return value must be of type Illuminate\Database\Eloquent\Model, string returned
the form model is either the class name of the model (if it doesnt exist) or the model instance
it there is no ticket set then you cannot pass it
for now you can probably leave out model() altogether
Ok, thank you. I'll give it a try.