-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Livewire component #7743
Livewire component #7743
Conversation
PR Summary
|
Few questions
|
Better to throw an exception if certain methods are not available as expected with other components. |
The component is a layout component (like tabs). I'm not sure but it cannot be dehydrated because it's not a field especially in an infolist.
Yes, you can pass a component like this: \Filament\Infolists\Components\Livewire::make(\App\Livewire\Foo::class, ['foo' => 'bar'])
The same methods from Thanks for getting attention to my PR! |
Make passing record optional as a component data param. Current usage: use Filament\Forms\Components\Livewire;
Forms\Components\Livewire::make('foo', ['record' => $infolist->getRecord(), 'bar' => 'qux']) // Livewire component
class Foo extends Component
{
public function mount(array $componentData = []): void
{
$this->data = $componentData;
} |
I see, that makes a lot of sense now.
not LW expert but this feels unsafe, as LW doc never (I might be wrong) show examples of using would suggest to have some checking if the name passed in is a livewire component, and also resolve the name public static function make($component, $data){
// .... check if is valid livewire component
$this->componentName = $component::getName();
// ...
}
// in blade
@livewire($componentName, $data) |
I don't use it like this. Current usage in blade.php: @livewire($component, compact('componentData')) |
Can you add lazy load support too? Livewire::make(\App\Livewire\Foo::class, ['foo' => 'bar'])->lazy() |
I'm using method view from |
I mean this implementation https://livewire.laravel.com/docs/lazy |
Oh sorry, I didn't understand. Now I'm using blade directive |
I think this will work |
Update usage of component. \Filament\Forms\Components\Livewire::make(\App\Livewire\Foo::class)
->lazy()
->withRecord()
->componentData(['bar' => 'form']) @rahmanramsi now it's supports |
How it goes with if livewire/livewire#5780 get merged some day? |
This component is part of a form or an infolist so it can't be a full-page livewire component. Despite that, I call livewire component in native way via |
Hi, thanks for the PR. I think it's important to give you a bit of information as to why this PR has been tagged as "low priority". We really appreciate all contributions, and intend to visit this in the future, and hopefully merge it if it is a suitable feature for the framework. However, reviewing PRs, and often rewriting them on behalf of the author to ensure they are consistent with the rest of the framework, consumes a lot of my time. At the moment we have a large backlog of bug reports that I am prioritising, since most of these affect functionality that worked in a previous version and are now impacting real projects. Hopefully you can see how that work comes first before introducing new features that people aren't using in projects yet. Again, thank you for contributing and I'm looking forward to reviewing this PR when our backlog of bug reports has reduced. |
Thanks! |
@njxqlus Thanks for your work on this. I wanted to find something out I am struggling with. I am wanting to use this to add a livewire component essentially as a custom step in my Form Wizard. The issue I'm facing is getting the livewire component to essentially be part of the form flow? i.e. the component has form awareness. So in the livewire component I can perform logic with the current state of the form if that makes sense? I'm not sure if you can help, I see that you state in the docs that when being used for a new record creation it can be hidden, but I'm wanting to use this as part of the form wizard flow for new and existing records. just thought I'd reach out as I've been battling with this for a little while now. |
@Nicholasbell03 I'm not sure about what you want to achieve. Wizard is just a layout so you can use it with any components inside. From docs:
|
@njxqlus thank you for your response. Perhaps an example.
So the livewire component needs the current raw state of the parent filament form at all times if that makes sense? This is a really basic example, but I think it expresses the same problem I have. I've found a way to do this with event dispatch and a listener inside the livewire component, but it seems like a hacky approach. I'm not sure if I am missing something really obvious here and just can't see the wood from the trees. Many thanks again for the feature you added and taking the time to respond. |
As discussed in #7735