F
Filament8mo ago
Mocus

Add info list to Page (with no resource)

I've read through the docos ... i've created a page with no resource and edited the pages/page.php like so
<?php

namespace App\Filament\App\Pages;

use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Pages\Page;

class bpa extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.app.pages.bpa';

public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->state([
'name' => 'MacBook Pro',
'category' => [
'name' => 'Laptops',
],
// ...
])
->schema([
TextEntry::make('name'),
TextEntry::make('category.name'),
// ...
]);
}
}
<?php

namespace App\Filament\App\Pages;

use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Pages\Page;

class bpa extends Page
{
protected static ?string $navigationIcon = 'heroicon-o-document-text';

protected static string $view = 'filament.app.pages.bpa';

public static function infolist(Infolist $infolist): Infolist
{
return $infolist
->state([
'name' => 'MacBook Pro',
'category' => [
'name' => 'Laptops',
],
// ...
])
->schema([
TextEntry::make('name'),
TextEntry::make('category.name'),
// ...
]);
}
}
but this isnt displaying, i get the nav link fine thou
15 Replies
toeknee
toeknee8mo ago
Are you rendering the info list into the view blade?
Mocus
MocusOP8mo ago
i've not touched the view blade file the way im readying the doco's is if i make a custome view for the resource i shouldnt need to? so just an update, i've created a CustomePage -> with Resource this is my page:
@livewire('view-product')
<div>
{{ $this->someList }}
{{-- If your happiness depends on money, you will never be happy with yourself. --}}
</div>
@livewire('view-product')
<div>
{{ $this->someList }}
{{-- If your happiness depends on money, you will never be happy with yourself. --}}
</div>
and this is my customPages class php
class ListItem extends Page implements HasForms, HasInfolists
{
use InteractsWithForms;
use InteractsWithInfolists;

protected static string $resource = IndustryblueprintsResource::class;

protected static string $view = 'filament.app.resources.industryblueprints-resource.pages.list-item';

public static function someList(Infolist $infolist): Infolist
{
return $infolist
->state([
'name' => 'MacBook Pro',
'category' => [
'name' => 'Laptops',
],
// ...
])
->schema([
TextEntry::make('name'),
TextEntry::make('category.name'),
// ...
]);
}
}
class ListItem extends Page implements HasForms, HasInfolists
{
use InteractsWithForms;
use InteractsWithInfolists;

protected static string $resource = IndustryblueprintsResource::class;

protected static string $view = 'filament.app.resources.industryblueprints-resource.pages.list-item';

public static function someList(Infolist $infolist): Infolist
{
return $infolist
->state([
'name' => 'MacBook Pro',
'category' => [
'name' => 'Laptops',
],
// ...
])
->schema([
TextEntry::make('name'),
TextEntry::make('category.name'),
// ...
]);
}
}
i've adjusted my resource route like so 'index' => Pages\ListItem::route('/'), so when i click on the link it takes me to this page but the damn info list isnt showing and it's really got me stumped.
toeknee
toeknee8mo ago
It won’t show unless you call it in the view blade as per. https://filamentphp.com/docs/3.x/infolists/adding-an-infolist-to-a-livewire-component#adding-the-infolist Which looking at your last comment you have now. What happens when you access the page.
Mocus
MocusOP8mo ago
it's blank =/
No description
Mocus
MocusOP8mo ago
still no luck with this, any idea's?
irfancan
irfancan8mo ago
you need to add HasForms, HasInfolists interfaces and instead of extending Page try custom component?
Mocus
MocusOP8mo ago
i've add them to the custom page php?
implements HasForms, HasInfolists
implements HasForms, HasInfolists
is that not the right way?
Mocus
MocusOP8mo ago
so this is what i have right now: in my sortBP.php my class is as follows:
class SortBP extends Page implements HasForms, HasInfolists
{
use InteractsWithForms, InteractsWithInfolists;

public function infolist(Infolist $infolist): Infolist
{
return $infolist
->state([
'name' => 'MacBook Pro',
'category' => [
'name' => 'Laptops',
],
// ...
])
->schema([
TextEntry::make('name'),
TextEntry::make('category.name'),
// ...
]);
}

protected static string $resource = BPOResource::class;

protected static string $view = 'filament.app.resources.b-p-o-resource.pages.sort-b-p';
}
class SortBP extends Page implements HasForms, HasInfolists
{
use InteractsWithForms, InteractsWithInfolists;

public function infolist(Infolist $infolist): Infolist
{
return $infolist
->state([
'name' => 'MacBook Pro',
'category' => [
'name' => 'Laptops',
],
// ...
])
->schema([
TextEntry::make('name'),
TextEntry::make('category.name'),
// ...
]);
}

protected static string $resource = BPOResource::class;

protected static string $view = 'filament.app.resources.b-p-o-resource.pages.sort-b-p';
}
from what i understand this should inject it into the page without needing to edit the blade.php file?
No description
Mocus
MocusOP8mo ago
my page loads but it's empty
awcodes
awcodes8mo ago
You still have to modify the blade file.
Mocus
MocusOP8mo ago
ok, so i've added @livewire('sort-b-p-o') to my page, not it errors saying it cant find component? so i now have in my sort-b-p.blade.php file:
@livewire('sort-b-p')
<x-filament-panels::page>
{{ $this->infolist }}
</x-filament-panels::page>
@livewire('sort-b-p')
<x-filament-panels::page>
{{ $this->infolist }}
</x-filament-panels::page>
awcodes
awcodes8mo ago
You don’t need the @livewire. The page is the livewire component. $this->infolist should be all you need at a minimum.
Mocus
MocusOP8mo ago
aha finally! ok awsome thats working now with a plan list, next how do i inject/use my $model property from the resource?
Mocus
MocusOP8mo ago
this doesnt explain how i access the mode from the resource, the resource is exposed but i cant access it using record/model/modelname so after a few hours trying i can see how you use the model from your resrouce in this
Want results from more Discord servers?
Add your server