EleventhTower
EleventhTower
FFilament
Created by EleventhTower on 4/16/2025 in #❓┊help
Hide Column Based on Active Group?
What is the easiest way to achieve something like this:
Tables\Columns\TextColumn::make('affiliate_name')
->label('Affiliate')
->hidden(fn() => $table->getActiveGroup() === 'affiliate_name')
Tables\Columns\TextColumn::make('affiliate_name')
->label('Affiliate')
->hidden(fn() => $table->getActiveGroup() === 'affiliate_name')
1 replies
FFilament
Created by EleventhTower on 4/15/2025 in #❓┊help
DateRangeFilter - Table doesn't update until I force refresh
I've been struggling with this for several days and am not getting past the issue. I have a filter that I execute that properly updates the header to the table with the indicateUsing method. However, the records in the table don't update until I actually refresh the page. How can I make it so that when I submit the filter the table records are re-queried based on my query modifications. """ ->filters([ DateRangeFilter::make('date_range') ->label('Date Range') ->displayFormat('MM/DD/YYYY') ->format('m/d/Y') ->useRangeLabels(true) ->modifyQueryUsing(function (Builder $query, ?Carbon $startDate, ?Carbon $endDate) { if (empty($startDate) || empty($endDate)) { return $query; } return $query->withDateRange($startDate, $endDate); }) ->indicateUsing(function (array $data): ?string { if (!$data['date_range']) { return null; } return 'Date range: ' . $data['date_range']; }) ]) """ I've tried using things like filtersApplyAction, I've passed in $livewire as a component, as well as HasTable. Tried doing things with refreshTable as well as getTableRecords()->fresh() etc. None of it is working. Any help is appreciated.
1 replies
FFilament
Created by EleventhTower on 4/6/2024 in #❓┊help
Using Related Field Data in Validation Messages
Can anyone tell me how to pass related data into the Validation message? Currently, this works as I want it to; I just need a better error message.
Select::make('entity_type_id')
->label('Entity Type')
->relationship('entityType', 'name')
->required(),
TextInput::make('name')
->required()
->unique('entities', 'name')
->validationMessages([
'unique' => 'This {{I want to display entityType.name here}} already has an attribute with this name.',
])
->maxLength(255),
Select::make('entity_type_id')
->label('Entity Type')
->relationship('entityType', 'name')
->required(),
TextInput::make('name')
->required()
->unique('entities', 'name')
->validationMessages([
'unique' => 'This {{I want to display entityType.name here}} already has an attribute with this name.',
])
->maxLength(255),
4 replies
FFilament
Created by EleventhTower on 4/5/2024 in #❓┊help
Test Slideover is Visible
I want to test that a slideOver edit action is visible. I have this on my ViewRecord:
<?php

namespace App\Filament\Resources\EntityTypeResource\Pages;

use App\Filament\Resources\EntityTypeResource;
use App\Models\EntityType;
use Filament\Actions\EditAction;
use Filament\Resources\Pages\ViewRecord;

class ViewEntityType extends ViewRecord
{
protected static string $resource = EntityTypeResource::class;

protected function getHeaderActions(): array
{
return [
EditAction::make()
->slideOver()
->form(EntityType::getForm()),
];
}
}
<?php

namespace App\Filament\Resources\EntityTypeResource\Pages;

use App\Filament\Resources\EntityTypeResource;
use App\Models\EntityType;
use Filament\Actions\EditAction;
use Filament\Resources\Pages\ViewRecord;

class ViewEntityType extends ViewRecord
{
protected static string $resource = EntityTypeResource::class;

protected function getHeaderActions(): array
{
return [
EditAction::make()
->slideOver()
->form(EntityType::getForm()),
];
}
}
This is the PEST test I am trying to run:
it('renders the edit slideover', function () {
$entityType = EntityType::factory()->create();
livewire(ViewEntityType::class, ['record' => $entityType->getRouteKey()])
->mountAction(['edit'])
->callAction(['edit'])
->assertSee('Save changes');
});
it('renders the edit slideover', function () {
$entityType = EntityType::factory()->create();
livewire(ViewEntityType::class, ['record' => $entityType->getRouteKey()])
->mountAction(['edit'])
->callAction(['edit'])
->assertSee('Save changes');
});
I have tried multiple variations of this, but I need some more direction. Thanks.
2 replies