Filament allows you to build Clusters (a grouped second-level navigation). But typically, it's only for List
pages. What if we want to have them in the Create/Edit pages:
To do this, there's a straightforward function we can add:
app/Filament/Resources/UserResource/Pages/CreateUser.php
class CreateUser extends CreateRecord{ protected static string $resource = UserResource::class; public function getSubNavigation(): array { if (filled($cluster = static::getCluster())) { return $this->generateNavigationItems($cluster::getClusteredComponents()); } return []; }}
This will render our Cluster as Sub Navigation.
The same works for the Edit page:
app/Filament/Resources/UserResource/Pages/EditUser.php
class EditUser extends EditRecord{ protected static string $resource = UserResource::class; protected function getHeaderActions(): array { return [ Actions\DeleteAction::make(), ]; } public function getSubNavigation(): array { if (filled($cluster = static::getCluster())) { return $this->generateNavigationItems($cluster::getClusteredComponents()); } return []; }}
A few of our Premium Examples: