F
Filament10mo ago
SirFat

Referring to Stand-alone livewire component (form builder) via direct route

Hi, I had previously marked a similar thread as solved as I thought I was onto the solution, but I was wrong. Background: "I'm attempting to create a livewire component with a filament form in it (that bit is fine) - and then using a route to get to the component directly. Unfortunately, despite creating a layout specifically for this purpose and pointing to it, it includes livewire and filament includes, the wizard I'm attempting to show is still missing some vital component to make it render correctly. How would I go about finding out what it is?" I ended up getting the LiveWire component to render correctly by overriding the layout, but I'm thinking that wasn't the correct path. OK - this did not solve it, because while using a layout does allow the CSS and Scripts for filament/livewire to be accessible, because it's a layout and not something called via 'view', it isn't evaluated to populate any of the properties (such as $title for example) in the layout file. Route:
Route::get('/signup', OnlineSignup::class);
Route::get('/signup', OnlineSignup::class);
Render function:
public function render(): View
{
return view('livewire.online-signup')->layout('components.layouts.signup');
}
public function render(): View
{
return view('livewire.online-signup')->layout('components.layouts.signup');
}
I can get the heading which is set within the page using:
@props([
'heading' => $this->getHeading(),
'subheading' => $this->getSubheading(),
])
@props([
'heading' => $this->getHeading(),
'subheading' => $this->getSubheading(),
])
But this still seems the incorrect approach as there would be any number of variables (such as $title for example) - that would need to be correctly populated for the page to show. Have I taken a wrong turn and am using the wrong approach? Is there another way to show a livewire component that uses the form builder in a direct (unauthenticated) route? I did see a thread with Dan's input about unauthenticated pages and that the 'panel' isn't designed for this but I should be able to use the form builder independently.
No description
5 Replies
SirFat
SirFat10mo ago
Hiya! The only part I don’t have is the create method for submission, but this is the initial render
dwong98
dwong9810mo ago
have you done any $this->form in your livewire components?
cheesegrits
cheesegrits10mo ago
When rendering forms "stand alone" on your front end, outside of a panel, you are responsible for everything on the page outside of the actual form. So if you look at the example component on that link dwong98 pointed to, all that is going to render is the form itself, e.g. just what you have in the form() method that returns the $form object. Form fields, groups, submit button, etc. No page heading, no title, no menus, no breadcrumbs. Just a page with a form on it, and whatever you have in your main layout. Within an admin panel, in the FooResource, you get a lot of extra stuff, like the heading. But that's only relevant in the admin panel. So yes, you need to provide those things, either as properties or getter functions, in your Livewire component.
SirFat
SirFat10mo ago
Okay - so while not ideal, I will have to setup everything. Just need to make sure that whatever is supplied via layout doesn’t require dynamic behaviour, from the sound of it. That said, what is peculiar is filament() IS available within the layout, so maybe extending that to support more things may get me out of trouble as much as it feels a little square peg, round hole.