F
Filament7mo ago
kool

Infolist/form not appears in relation manager

I have a relation manager that get displayed in the resource edit page. The table is rendered correctly but there is no form neither infolist appears in the page. I couldn't find the reason of the problem, I also tried to upgrade to the recent version and run filament:upgrade but nothing happen.
7 Replies
kool
koolOP7mo ago
No description
kool
koolOP7mo ago
<?php

namespace App\Filament\Resources\TransferBatchResource\RelationManagers;

use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;

class TransfersRelationManager extends RelationManager
{
protected static string $relationship = 'transfers';

public function infolist(Infolist $infolist): Infolist
{
return $infolist
->columns(1)
->schema([
TextEntry::make('started_at'),
TextEntry::make('delivered_at'),
]);
}

public function form(Form $form): Form
{
return $form->schema([
TextInput::make('started_at'),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('transfer_id');
->columns(...)
->defaultGroup(static::getTableGroup)
}

private static function getTableGroup(): Tables\Grouping\Group {}

protected function paginateTableQuery(Builder $query): Paginator {}
}
<?php

namespace App\Filament\Resources\TransferBatchResource\RelationManagers;

use Filament\Forms\Components\TextInput;
use Filament\Forms\Form;
use Filament\Infolists\Components\TextEntry;
use Filament\Infolists\Infolist;
use Filament\Resources\RelationManagers\RelationManager;
use Filament\Tables;
use Filament\Tables\Table;
use Illuminate\Contracts\Pagination\Paginator;
use Illuminate\Database\Eloquent\Builder;

class TransfersRelationManager extends RelationManager
{
protected static string $relationship = 'transfers';

public function infolist(Infolist $infolist): Infolist
{
return $infolist
->columns(1)
->schema([
TextEntry::make('started_at'),
TextEntry::make('delivered_at'),
]);
}

public function form(Form $form): Form
{
return $form->schema([
TextInput::make('started_at'),
]);
}

public function table(Table $table): Table
{
return $table
->recordTitleAttribute('transfer_id');
->columns(...)
->defaultGroup(static::getTableGroup)
}

private static function getTableGroup(): Tables\Grouping\Group {}

protected function paginateTableQuery(Builder $query): Paginator {}
}
// Resource file

public static function getRelations(): array
{
return [
TransfersRelationManager::class,
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListTransferBatches::route('/'),
'edit' => Pages\EditTransferBatch::route('/{record}/edit'),
];
}
// Resource file

public static function getRelations(): array
{
return [
TransfersRelationManager::class,
];
}

public static function getPages(): array
{
return [
'index' => Pages\ListTransferBatches::route('/'),
'edit' => Pages\EditTransferBatch::route('/{record}/edit'),
];
}
I tried using ManageRelatedRecords and same occurs Can't I display a form/infolist with a table in the the same page?
kool
koolOP7mo ago
I want to achieve something like this
No description
Tieme
Tieme7mo ago
@kool The code of the Demo page is in Github, have you looked at how the have made it? https://github.com/filamentphp/demo/blob/main/app/Filament/Resources/Shop/OrderResource.php Infolist it never used on Edit Page. It is https://filamentphp.com/docs/3.x/forms/layout/placeholder
kool
koolOP7mo ago
I didn't know about, I think it is a recent feature. I managed to solve it using the approach in the demo, using a sub resource navigation. I created two pages one for relations and one for viewing details and can navigate between them
kool
koolOP7mo ago
No description
kool
koolOP7mo ago
thank you @Tieme
Want results from more Discord servers?
Add your server