Craig Potter
Craig Potter
FFilament
Created by Craig Potter on 10/11/2024 in #❓┊help
Whats the best way to use Filament Tables in a Custom Package
So I am making a Laravel package and part of that is a small UI. I would love to use Filament Tables on that UI as it would solve most of the problems and save a bunch of time but my question is what is the best way. The installing project may or may not have filament installed. Whats the best way to include the assets regarded for Filament?
7 replies
FFilament
Created by Craig Potter on 8/14/2024 in #❓┊help
testing table action
Maybe I am being dumb but hopefully someone can help. I have a simple Resource that has a table and it also has a custom page. The custom page is listed in the getPages() function on the resource
public static function getPages(): array
{
return [
'stats' => Pages\FirmStats::route('/{record}/stats'),
];
}
public static function getPages(): array
{
return [
'stats' => Pages\FirmStats::route('/{record}/stats'),
];
}
I have a row action to open a new custom page.
$table->columns(...)->actions([
Tables\Actions\Action::make('stats')
->icon('heroicon-o-chart-pie')
->label('Stats')
->url(fn (Firm $record): string => FirmResource::getUrl('stats', ['record' => $record])),
])
$table->columns(...)->actions([
Tables\Actions\Action::make('stats')
->icon('heroicon-o-chart-pie')
->label('Stats')
->url(fn (Firm $record): string => FirmResource::getUrl('stats', ['record' => $record])),
])
This works fine in the browser. It opens the URL as expected. I'm trying to write a simple test and I can't work out how. I am looking at the docs here https://filamentphp.com/docs/3.x/tables/testing#url and there should be a simple assertTableActionHasUrl However when I use that in our test it fails because the Action isn't loading the current record in to the Action and I'm not sure how to proceed.
test('firms have a link to their stats page', function() {
$firm = Firm::factory()->create();

livewire(FirmResource\Pages\ListFirms::class)
->loadTable()
->assertCanSeeTableRecords([$firm])
->assertTableActionExists('stats')
->assertTableActionHasUrl('stats', FirmResource::getUrl('stats', ['record' => $firm]));
});

// TypeError: App\Filament\Resources\FirmResource::App\Filament\Resources\{closure}(): Argument #1 ($record) must be of type App\Models\Firm, null given
test('firms have a link to their stats page', function() {
$firm = Firm::factory()->create();

livewire(FirmResource\Pages\ListFirms::class)
->loadTable()
->assertCanSeeTableRecords([$firm])
->assertTableActionExists('stats')
->assertTableActionHasUrl('stats', FirmResource::getUrl('stats', ['record' => $firm]));
});

// TypeError: App\Filament\Resources\FirmResource::App\Filament\Resources\{closure}(): Argument #1 ($record) must be of type App\Models\Firm, null given
So the error is happening on the ->url(fn(Firm $record)) in the action... Any advice ?
2 replies
FFilament
Created by Craig Potter on 10/13/2023 in #❓┊help
Pasting in to a tagsInput splits a string
I'm not sure if this is a feature or a bug but if you have a simple tagsInput field and you paste a string in, it appears to be splitting it in to different tags
TagsInput::make('test');
TagsInput::make('test');
Is this the correct functionality or is there a way to stop it so it just accepts the entire string ?
8 replies
FFilament
Created by Craig Potter on 10/6/2023 in #❓┊help
TagsInput Validation on Custom Livewire Component
Hi, I'm using a TagsInput on a custom livewire component. The form works fine and I followed https://filamentphp.com/docs/3.x/forms/adding-a-form-to-a-livewire-component The issue I have it is the validation seems never be displayed.
public function form(Form $form): Form
{
return $form
->schema([
TagsInput::make('id_numbers')
->hiddenLabel()
->placeholder('Enter ID Numbers')
->hiddenOn('create')
->nestedRecursiveRules([
'int',
])
->live(),
])
->statePath('data');
}
public function form(Form $form): Form
{
return $form
->schema([
TagsInput::make('id_numbers')
->hiddenLabel()
->placeholder('Enter ID Numbers')
->hiddenOn('create')
->nestedRecursiveRules([
'int',
])
->live(),
])
->statePath('data');
}
If I try and add ABC as a tag, I can see the error in the Livewire response has an error
{
"errors\":{\"data.id_numbers.0\":[\"The data.id_numbers.0 must be an integer.\"]}
}
{
"errors\":{\"data.id_numbers.0\":[\"The data.id_numbers.0 must be an integer.\"]}
}
but it never gets displayed on the frontend? Not sure if I am missing something?
3 replies
FFilament
Created by Craig Potter on 4/13/2023 in #❓┊help
Repeater on a simple json column
So i have a simple json column which just stores an list of items.
["apples", "pears", "oranges", "filamentIsGreat"]
["apples", "pears", "oranges", "filamentIsGreat"]
As you can see there is no keys. In my model it is cast as an array. Is it possible to use a repeater field to manage these? Or a better way? I couldn't work it out or see anything in the docs
5 replies
FFilament
Created by Craig Potter on 3/23/2023 in #❓┊help
How to use current Login
Hi, Is it possible to to disable the filament admin login page and use an existing login ?
13 replies