Hugo
Hugo
FFilament
Created by Hugo on 6/6/2024 in #❓┊help
Import / Export Session expired & logout - Export with random table info.
Hello. I've been having this issue for a while now. When I use the Export Action, in some cases, my session gets expired. I solved this issue by adding in the VerfifyCsrfToken middleware.
protected $except = [
'livewire/*'
];
protected $except = [
'livewire/*'
];
Although the issue of getting my session expired is solved, it now logs me out of the app. The export is still in the notifications and ready to download, but why does it log me out of my own app when pressing an export action? Another issue I've been having with the export action is the fact that the files come with some random data from other tables.
4 replies
FFilament
Created by Hugo on 5/11/2024 in #❓┊help
Dynamic columns on Importer class
Hello, I am trying to create dynamic columns on my importer classes. I tried using importer options and passing in a client, because clients may have different columns than others. Some columns are always the same for every client but some have other types of columns. My goal was to pass in the client through the options and then loop through the extra columns of the specific client and create the ImportColumns in a dynamic way. What i found out was that I can't access $options in the getColumns method. is there a way to do this?
10 replies
FFilament
Created by Hugo on 4/30/2024 in #❓┊help
prevent ->searchable(isIndividual:true) from hiding when no records found
Hello, is there a way to prevent the individual column search from hiding when there is no record that matches the search? I would like it to persist even though there was no record found so i could just backspace instead of having to remove the filter by hand.
2 replies
FFilament
Created by Hugo on 4/12/2024 in #❓┊help
Send variables to the Exporter
I've got a resource with a table. I have a history table action which opens up a modal with several tabs with tables (several types of history from the selected record) inside. In the header of each table I wan't to add an ExportAction but i'd like to send through some variables (like the selected $record from the first table) so that I can have a column on the exporter just for that variable (yes the column will always have the same value). To give you proper context. You have a piece of clothing. You want to see the washing history that happened on that piece of clothing. Each washing process saves in a json column all the clothes it washed. To see through the history of a certain clothing, im retrieving all washing processes, getting all the articles it washed and compare them with the clothing $record i selected and then saving every washing process id. Then on the table im just showing the washing processes which id I saved. So the clothing piece has no direct relationship with the washing process. How can I send the $record variable (which is my clothign piece) to the exporter so that I can have a column with that information to export?
8 replies
FFilament
Created by Hugo on 4/12/2024 in #❓┊help
ExportAction on big amounts of rows.
Hello, im currently having a problem using ExportAction on a table with 50k rows. Upon trying, my session just expires and it logs me out of the app. I've tried playing around with the chunkSize as explained in the docs but to no success. Is there a workaround or a way to make this work? It generates the file still but the page keeps expiring.
2 replies
FFilament
Created by Hugo on 4/3/2024 in #❓┊help
sticky table header
Hello, I've searched this question here and all the solutions did not work, they did do something but not what I expected. I would like to know if anyone has implemented or has a solution for a sticky header on the tables. When scrolling down I would like the table header to follow through. Anyone?
6 replies
FFilament
Created by Hugo on 3/20/2024 in #❓┊help
Prevent Individual search fields from hiding when no results
Is there a way to prevent the individual searches on a table to hide when I get no results ? I say this because it is kinda annoying to have to go and press to clear filters when I could simply just backspace, just like it is in the global search.
2 replies
FFilament
Created by Hugo on 3/15/2024 in #❓┊help
Theme doesn't apply on dashboard page
No description
11 replies
FFilament
Created by Hugo on 3/13/2024 in #❓┊help
Testing - how can i test if a from from a suffix action has a certain field?
Hello, im making tests on a form which has fields that have suffix actions. Im struggling trying to check whether a certain field is present in the form after I go into the suffix action. it asserts Successfully that the "open-modal" event was dispatched and It also asserts successfully that the label of my field is being shown. From this I know that im indeed in the modal. The problem im facing now is that I can't assert if a certain field exists because it says the form does not exist. This is what I have:
->assertFormComponentActionExists('identifier', 'changeIdentifier')
->mountFormComponentAction('identifier', 'changeIdentifier')
->assertDispatched("open-modal")
->assertSeeText("Identificador no ERP")
->assertFormFieldExists('notes','mountedFormComponentAction');
->assertFormComponentActionExists('identifier', 'changeIdentifier')
->mountFormComponentAction('identifier', 'changeIdentifier')
->assertDispatched("open-modal")
->assertSeeText("Identificador no ERP")
->assertFormFieldExists('notes','mountedFormComponentAction');
This last line is what is giving me errors, it says that the mountedFormComponentAction does not exist. Any help?
2 replies
FFilament
Created by Hugo on 2/23/2024 in #❓┊help
Dashboard navitem when active hides hooks by default?
No description
4 replies
FFilament
Created by Hugo on 2/22/2024 in #❓┊help
Render hook not working for 'panels:sidebar-nav.start'
Hello, Im trying to add a search option on top of my sidebar. For it, im tryng to render the following hook:
->renderHook('panels::sidebar-nav.start', fn() => view('tables.sidebar-search'))
->renderHook('panels::sidebar-nav.start', fn() => view('tables.sidebar-search'))
` this is in my AdminPanelProvider. I've rendered some hooks before and they are still working fine but I can't seem to be able to use this one. I tried using the sintax presented in the docs "PanelsRenderHook::SIDEBAR_NAV_START" https://filamentphp.com/docs/3.x/support/render-hooks#available-render-hooks, but is doesn't seem to work because apparently PanelsRenderHook doesn't exist. Anyone with the same problem?
3 replies
FFilament
Created by Hugo on 1/31/2024 in #❓┊help
Cannot press save changes button because of tabs in the form?
I am having a weird interaction in my edit form. I have a few tabs in my form where those tabs show different tables. For some odd reason, if I comment out those tabs or I just remove the table from the tab schema the save changes button works again. Those tabs have nothing to do nor will save anything alongside the form, they just show different tables where you can manage visibility of certain records. I'll follow up in the comments with code.
3 replies
FFilament
Created by Hugo on 1/11/2024 in #❓┊help
How to dispatch an event from a Notification Action
I've been trying to dispatch an event from a Notification Action but it's not working. using ->dispatch or ->dispatchSelf seems to do nothing. I've searched around and tried to use ->action() and dispatch using $livewire->dispatch() but action seems to not work on notification Actions. How can I rly dispatch an event from a Notification action?
Notification::make()
->success()
->title('Portador criado com sucesso!')
->actions([ \Filament\Notifications\Actions\Action::make('view')
->label('Ver Portador')
// ->url('/admin/business/clients/' .$client->id.'/edit?activeRelationManager=2',true)
->dispatchSelf('test-created')
])
->send();
Notification::make()
->success()
->title('Portador criado com sucesso!')
->actions([ \Filament\Notifications\Actions\Action::make('view')
->label('Ver Portador')
// ->url('/admin/business/clients/' .$client->id.'/edit?activeRelationManager=2',true)
->dispatchSelf('test-created')
])
->send();
Further down in my Resource, there's my method that is attempting to listen to the dispatch event but it never gets there.
#[On('test-event')]
public function test()
{
dd('here');
}
#[On('test-event')]
public function test()
{
dd('here');
}
Any Thoughts?
17 replies
FFilament
Created by Hugo on 1/9/2024 in #❓┊help
Confirmation modal before action.
Im trying to show a confirmation modal after pressing the submit button. At the moment it looks like this:
Action::make('generate_recap')
->label(__('events.recap.actions.create'))
->icon('fluentui-document-pdf-24-o')
->form(static::createRecapForm())
->action(function($data){
$client = Client::query()->where('id', $data['client_id'])->first();
(new PDFGenerator($data['client_id'],$data['delivery_address_id'], $data['month'], strval($data['year']), $data['contract']))->generateRecap();
}),
Action::make('generate_recap')
->label(__('events.recap.actions.create'))
->icon('fluentui-document-pdf-24-o')
->form(static::createRecapForm())
->action(function($data){
$client = Client::query()->where('id', $data['client_id'])->first();
(new PDFGenerator($data['client_id'],$data['delivery_address_id'], $data['month'], strval($data['year']), $data['contract']))->generateRecap();
}),
Adding an extraModalFooterAction and putting the submitAction to false could be a solution and i've tried it. The problem im running into is that I cant access the $data coming from the parent form. If I could access that $data I could probably execute the action I want upon confirming. What im looking for is: I have the action that I posted with my form. When I press the submit button I want a confirmation Modal to show. Upon confirming that modal I want to execute the action with the $data from the form.
2 replies
FFilament
Created by Hugo on 12/6/2023 in #❓┊help
[Tests] What's the way to fill a form that has a repeater ?
Im testing a relationManager and the create form has a repeater, im trying to fill the form with data but i'm having trouble filling the repeater. I thought the right way to fill a repeater would be with a nested array, so that's what im feeding it with.
it('can add a new client employee', function (): void {
$client = Client::query()->first();
$deliveryAddress = DeliveryAddress::query()->first();
ArticleType::factory()->createOne();
$article = ArticleType::query()->first();

expect(ClientEmployee::query()->count())->toBe(0);

$sizes = [
[
"XL",
"article_type_id" => $article->id
]
,
[
"size" => "L",
"article_type_id" => $article->id
]
];

$page = livewire(EmployeesRelationManager::class, [
'ownerRecord' => $client,
'pageClass' => EditClient::class,
])
->mountTableAction('create');

$page->fillForm([
"name" => "New Name",
"client_id" => $client->id,
"delivery_address_id" => $deliveryAddress->id,
'default_article_sizes' => $sizes,
], "mountedTableActionForm");
$page->callMountedTableAction()->assertHasNoFormErrors([], "mountedTableActionForm");

expect(ClientEmployee::query()->count())->toBe(1);
});
it('can add a new client employee', function (): void {
$client = Client::query()->first();
$deliveryAddress = DeliveryAddress::query()->first();
ArticleType::factory()->createOne();
$article = ArticleType::query()->first();

expect(ClientEmployee::query()->count())->toBe(0);

$sizes = [
[
"XL",
"article_type_id" => $article->id
]
,
[
"size" => "L",
"article_type_id" => $article->id
]
];

$page = livewire(EmployeesRelationManager::class, [
'ownerRecord' => $client,
'pageClass' => EditClient::class,
])
->mountTableAction('create');

$page->fillForm([
"name" => "New Name",
"client_id" => $client->id,
"delivery_address_id" => $deliveryAddress->id,
'default_article_sizes' => $sizes,
], "mountedTableActionForm");
$page->callMountedTableAction()->assertHasNoFormErrors([], "mountedTableActionForm");

expect(ClientEmployee::query()->count())->toBe(1);
});
Upon running this test im getting
Component has errors: "mountedTableActionsData.0.default_article_sizes.5f9ffbdc-8423-4daf-bc6a-68027546f90a.article_type_id", "mountedTableActionsData.0.default_article_sizes.5f9ffbdc-8423-4daf-bc6a-68027546f90a.size", "mountedTableActionsData.0.default_article_sizes.0.size"
Failed asserting that false is true.
Component has errors: "mountedTableActionsData.0.default_article_sizes.5f9ffbdc-8423-4daf-bc6a-68027546f90a.article_type_id", "mountedTableActionsData.0.default_article_sizes.5f9ffbdc-8423-4daf-bc6a-68027546f90a.size", "mountedTableActionsData.0.default_article_sizes.0.size"
Failed asserting that false is true.
Any solution?
2 replies
FFilament
Created by Hugo on 12/6/2023 in #❓┊help
[Testing] How to mount a table header action and make sure that the event was dispatched?
Im testing my application and currently testing a relation manager, but I'm having problems testing a table header action that creates a new record for that relation manager. It says that the event wasn't fired.
it('shows the create form for a new contract', function(): void {
$client = Client::query()->first();

livewire(ContractsRelationManager::class, [
'ownerRecord' => $client,
'pageClass' => EditClient::class,
])->assertSuccessful()
->assertTableHeaderActionsExistInOrder(['create'])
->mountAction('create')
->assertDispatched('open-modal');
});
it('shows the create form for a new contract', function(): void {
$client = Client::query()->first();

livewire(ContractsRelationManager::class, [
'ownerRecord' => $client,
'pageClass' => EditClient::class,
])->assertSuccessful()
->assertTableHeaderActionsExistInOrder(['create'])
->mountAction('create')
->assertDispatched('open-modal');
});
until the mountAction('create') the test run's fine but it then says it failed to assert that the event 'open-modal' was fired. Is there a way to test table header actions?
2 replies
FFilament
Created by Hugo on 11/20/2023 in #❓┊help
Pagination is showing vertically
No description
4 replies
FFilament
Created by Hugo on 11/6/2023 in #❓┊help
navigation bar fixed on the active navigation item
When the navigation items become too many, when I select a navigation item that is on the bottom of the navbar and I have to scroll for it, the page refreshes and the navbar goes back to the top. Is there a way to mantain the navbar position where the selected navbar item is?
15 replies
FFilament
Created by Hugo on 11/3/2023 in #❓┊help
How do correctly use the notification component?
Im quite new to filament and i'm trying to use the notifications component individually. Something like : <x-filament-notifications::notification :notification="$notification"/> now im just wondering what kind of data do I have to pass to the component in order for it to work? Im trying to show a notification using filament's notification but outside filament, but I just can't get it to work. My explanation might be quite confusing but I hope you understand what I'm trying to do. Im open for suggestions. Thank you in advance
2 replies