F
Filament2mo ago
Patie

Table update after action

Hi, im using filament as livewire components without full panel. On user detail page I have user infolist component - there is section with headerActions (form for adding user documents) and user document table inside schema.
Section::make('Documents')
->id('documents')
->headerActions([
Action::make('Add document')
->form($this->userDocumentForm->schema())
->action(function (array $data, User $user) {
$this->userDocumentForm->action($data, $user);
})
])
->schema([
Livewire::make(UserDocumentTable::class, ['userId' => $this->user->id])->key('user-document-table'),
]),
Section::make('Documents')
->id('documents')
->headerActions([
Action::make('Add document')
->form($this->userDocumentForm->schema())
->action(function (array $data, User $user) {
$this->userDocumentForm->action($data, $user);
})
])
->schema([
Livewire::make(UserDocumentTable::class, ['userId' => $this->user->id])->key('user-document-table'),
]),
what is correct way to update user document table to show updated data after create (or edit/delete) in my case? thank you!
8 Replies
awcodes
awcodes2mo ago
Dispatch a refresh to your livewire component.
Patie
Patie2mo ago
refresh whole component is only (correct) way when using standalone components? there is no way to reload only data on filament table or smth like this? thank you @awcodes
awcodes
awcodes2mo ago
Unless you have nested components then you have to refresh the whole component. Technically you shouldn’t have to if the data changes. The data change should just automatically do a rerender. Maybe also look into computed properties in livewire.
Patie
Patie2mo ago
not automatically re-rendered in my case, probably i have something wrong probably bcs i have it as Livewire::make 🤔 im using
->schema([
Livewire::make(UserDocumentTable::class, ['userId' => $this->user->id])->key('user-document-table'),
]),
->schema([
Livewire::make(UserDocumentTable::class, ['userId' => $this->user->id])->key('user-document-table'),
]),
because i want reuse existing table code, is there better way how to do it maybe?
awcodes
awcodes2mo ago
You should be able to dispatch a refresh to that specific component. Check out the livewire docs A computed property for the user might be better though.
Patie
Patie2mo ago
yes, emitting on whole component is working ofc, thx computed property probably should be on documents as table showing documents in rows, user is only for filtering
awcodes
awcodes2mo ago
Yea. Makes sense though. You need table to refresh and the main component is in charge of the table.
Patie
Patie2mo ago
hmm is strage dispatch not working from inside of
$this->userDocumentForm->action($data, $user);
$this->userDocumentForm->action($data, $user);
method, but only when its directly fired from action like this:
Section::make('Documents')
->id('documents')
->headerActions([
Action::make('Add document')
->form($this->userDocumentForm->schema())
->action(function (array $data, User $user) {
$this->userDocumentForm->action($data, $user);
$this->dispatch('user-document-created');

})
])
->schema([
Livewire::make(UserDocumentTable::class, ['userId' => $this->user->id])->key('user-document-table'),
]),
Section::make('Documents')
->id('documents')
->headerActions([
Action::make('Add document')
->form($this->userDocumentForm->schema())
->action(function (array $data, User $user) {
$this->userDocumentForm->action($data, $user);
$this->dispatch('user-document-created');

})
])
->schema([
Livewire::make(UserDocumentTable::class, ['userId' => $this->user->id])->key('user-document-table'),
]),
but i understand its more like livewire problem and not filament it's a pity that there is no way to insert the form from another file like nested component into section section (or into tab directly) and must be used Livewire here
Want results from more Discord servers?
Add your server
More Posts
mask with afterStateUpdated immediately submits formWhy does using the `mask()` method as well as the `afterStateUpdated` method on a `TextInput` make tMultiple levels of relationships and chatGPTRooms are rarely changed (it's just names such as Kitchen, Bedroom 1 etc). A property has many roomsConditional filter rendering by $activeTabHello! I'm using the active tab to decide visibility like [here](<https://discord.com/channels/88308How to use external links in table builder? Please helpI'm new to Filament and I'm having trouble accessing an external link. I have a client resource, andTrouble Displaying / Updating Pivot Table Data with Same Names as Parent Model**Problem Description:** I'm having trouble showing, updating data from a pivot table. The issue isSelectFilter search in multiple columns - Is this intendedHello, I am working on a resource where i am looking into filtering and i found out that a SelectFSetting a field as part of a clone actionI've been playing around with this but couldn't figure it out, I want to modify the builder clone acDeferred loading with form in laravel componentI have a slideover in a livewire component where I'm using deferred loading, so that the model isn'tModel Policy on page not workingI followed this https://filamentphp.com/docs/3.x/tables/adding-a-table-to-a-livewire-component#addinShow which tabs have form errors when a form is submittedI have an "Infolist" page with entries organized in tabs. To keep the UI consistent and a pleasant e