F
Filament11mo ago
jals65

Issue with modal in actions

Hi, I'm building a table with a custom livewire component with table builder in a custom page. The problem is when I add a action in the table and i want to open a modal with a form to get data before exec the action. It doesn't open the modal. I link the Custom page and the visual-testing-baselines component files.
Solution:
Returning all the fields and deleting the getTableQuery() function has already worked for me. ``` protected function getTableQuery(): Builder|Relation { if (!empty($this->project)) {...
Jump to solution
15 Replies
jals65
jals6511mo ago
As you can see in the VisualTestingBaselines.php i'm adding the action by this way:
protected function getTableActions(): array
{
return [
Action::make('duplicar')
->form([
TextInput::make('name')
])
->action(function ($record, $data, VisualTestsServiceInterface $visualTestsService) {
Filament::notify('success', 'Baselines deleted');
})
->requiresConfirmation()
];
}
protected function getTableActions(): array
{
return [
Action::make('duplicar')
->form([
TextInput::make('name')
])
->action(function ($record, $data, VisualTestsServiceInterface $visualTestsService) {
Filament::notify('success', 'Baselines deleted');
})
->requiresConfirmation()
];
}
In other filament tables in the list record it works, but in a component in a custom page with table builder it doesn't works. Somebody can help me?
Vp
Vp11mo ago
Hi, I've just check it out and it's working fine, my code is below
<?php

namespace App\Http\Livewire;

use App\Models\User as ModelsUser;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Livewire\Component;

class User extends Component implements Tables\Contracts\HasTable
{
use Tables\Concerns\InteractsWithTable;

protected function getTableQuery(): Builder
{
return ModelsUser::query();
}

protected function getTableColumns(): array
{
return [
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('email'),
];
}

protected function getTableActions(): array
{
return [
Tables\Actions\Action::make('duplicar')
->action(function ($record, $data) {
dd($data);
})
->requiresConfirmation(),
];
}

public function render()
{
return view('livewire.user');
}
}
<?php

namespace App\Http\Livewire;

use App\Models\User as ModelsUser;
use Filament\Tables;
use Illuminate\Database\Eloquent\Builder;
use Livewire\Component;

class User extends Component implements Tables\Contracts\HasTable
{
use Tables\Concerns\InteractsWithTable;

protected function getTableQuery(): Builder
{
return ModelsUser::query();
}

protected function getTableColumns(): array
{
return [
Tables\Columns\TextColumn::make('name'),
Tables\Columns\TextColumn::make('email'),
];
}

protected function getTableActions(): array
{
return [
Tables\Actions\Action::make('duplicar')
->action(function ($record, $data) {
dd($data);
})
->requiresConfirmation(),
];
}

public function render()
{
return view('livewire.user');
}
}
Ashk
Ashk11mo ago
You need to have <x-filament-actions::modals /> in your page component
jals65
jals6511mo ago
That doesn't works.
Unable to locate a class or view for component [filament-actions::modals].
Unable to locate a class or view for component [filament-actions::modals].
The problem I see is as if the Actions themselves were broken. It must be due to a lack of some dependency or something because they are painted correctly but when I press they do nothing, as if the script that makes them work was missing. Even if I remove the modals, and leave only the action, it doesn't work, it doesn't execute the ->action()
Action::make('duplicar')
->action(function ($record, $data, VisualTestsServiceInterface $visualTestsService) {
Filament::notify('success', 'Baselines deleted');
})
Action::make('duplicar')
->action(function ($record, $data, VisualTestsServiceInterface $visualTestsService) {
Filament::notify('success', 'Baselines deleted');
})
Ashk
Ashk11mo ago
Are you using filament panel or you install table package without panel package ?
Ashk
Ashk11mo ago
If you use table outside of panel package, you should install https://filamentphp.com/docs/3.x/actions/installation
Ashk
Ashk11mo ago
Your error is clear, the component is missing Unable to locate a class or view for component [filament-actions::modals].
jals65
jals6511mo ago
I'm in v2. Does that affect anything?
Ashk
Ashk11mo ago
ahhhhhhh probably, I don't know
jals65
jals6511mo ago
I have this 2 packages: "filament/filament": "^2.0", "filament/forms": "^2.0",
awcodes
awcodes11mo ago
you shouldn't need both installed like that. 'filament/filament' installs all the packages.
jals65
jals6511mo ago
Yes, I remove it. But the problem that I have with the actions in the custom table continues
jals65
jals6511mo ago
I have debugged and I have seen that the action breaks here. vendor/filament/tables/src/Concerns/HasActions.php
jals65
jals6511mo ago
I have solved the problem. The problem was caused because in the getTableQuery() I was not returning the key. That forced me to use the getTableRecordKey() function to set a new one. This meant that the actions could not take the Record.
Solution
jals65
jals6511mo ago
Returning all the fields and deleting the getTableQuery() function has already worked for me.
protected function getTableQuery(): Builder|Relation
{
if (!empty($this->project)) {
return VisualTestingBaseline::where(VisualTestingBaselineInterface::PROJECT, $this->project)->selectRaw('*, JSON_LENGTH(screenshots) AS num_screenshots');
}

return VisualTestingBaseline::query();
}
protected function getTableQuery(): Builder|Relation
{
if (!empty($this->project)) {
return VisualTestingBaseline::where(VisualTestingBaselineInterface::PROJECT, $this->project)->selectRaw('*, JSON_LENGTH(screenshots) AS num_screenshots');
}

return VisualTestingBaseline::query();
}
Want results from more Discord servers?
Add your server
More Posts
multiple() fields on /create return nullFull Disclosure: very inexperienced with Filament and php in general. Began this project a while agNotifications appearing below modal backdropon version 2.17.52 sending a notification through ->before() method from an action modal, shows it bdoes RelationManager support navigating to view instead of modal view?does RelationManager support navigating to view instead of modal view?Update default filament user factoryHow can I update the filament user factory (`php artisan make:filament-user`) I added columns like fFilament\FilamentManager::getUserName(): Return value must be of type string, null returnedIs it possible to edit the user at Filament? I want instead of the name column, the columns firstnamDisplaying a description with HTML tag or entity on TextColumnis there any way to add html entity or tag inside `->description()` on a table row? i have tried as Unable to use colors on blade components in livewire form componentI have created a livewire form component using docs from https://filamentphp.com/docs/3.x/forms/addiTable header actions not showing in view pageHow do you show the `headerActions` of a relation manager inside a view page resource? It only showsComponent not found after changing a ->live() elementHello, i have created a full page component which uses a form and a select live field to conditionalCustomize modal width in simple resource default create and edit actionIs it possible to change the modal width inside of resource's form static method?