F
Filament11mo ago
jop00

Hide relationship manager table from Edit view

Hi I want to hide the relationship manager table from the Edit view. I can't find how to do it.
Once a table and form have been defined for the relation manager, visit the Edit or View page of your resource to see it in action.
5 Replies
Patrick Boivin
Patrick Boivin11mo ago
You want to have the relation manager only on Create?
jop00
jop0011mo ago
Only on View. It's a very big form and it won't be necessary to have the realtion table. I just want to know if it's a way to hide the relation manager table.
Patrick Boivin
Patrick Boivin11mo ago
I think the simplest way would be to hide it with CSS Another idea: You could override the getRelationManagers() method on the specific page class (eg. EditPost) and return an empty array
jop00
jop0011mo ago
Thanks public static function getRelations(): array { if (request()->route()->getName() == 'filament.admin.resources.posts.view') { return [ RelationManagers\SubmissionsRelationManager::class, ]; }else{ return []; } } I've done this and it's working
Ric Le Poidevin
Ric Le Poidevin10mo ago
For anyone landing here, this is what I needed to do as the route could be null:
public static function getRelations(): array
{
if (request()->route()?->getName() === 'filament.admin.resources.vacancies.view') {
return [
RelationManagers\ApplicationsRelationManager::class,
];
} else {
return [];
}
}
public static function getRelations(): array
{
if (request()->route()?->getName() === 'filament.admin.resources.vacancies.view') {
return [
RelationManagers\ApplicationsRelationManager::class,
];
} else {
return [];
}
}