Closed Thiktak closed 1 year ago
Hello,
It's not possible, to use dynamic closure on the label attribute of PageNavigationItem.
public static function sidebar(Model $record): FilamentPageSidebar { return FilamentPageSidebar::make() ->setTitle($record) ->setDescription('Long text') ->setNavigationItems([ PageNavigationItem::make('Dashboard') ->label(fn () => __($record->kind . ' dashboard')) // Dynamic label ->label(fn () => static::getUrl('view', ['record' => $record->id]) ); ->icon('heroicon-o-bookmark'), PageNavigationItem::make('Organization') ->label('Organization') // Fixed string label ->label(fn () => static::getUrl('org', ['record' => $record->id]) ); ->icon('heroicon-o-user-group'), ]); }
Calling the parent method, to benefit of evaluate method (NavigationItem::getLabel).
evaluate
By the way, maybe evaluate can be used for isHiddenWhen ?
public function isHiddenWhen(Closure|bool $condition): static { $this->isHidden = $this->evaluate($condition); return $this; }
Kudos, SonarCloud Quality Gate passed!
0 Bugs 0 Vulnerabilities 0 Security Hotspots 0 Code Smells
No Coverage information No Duplication information
Added also for FilamentPageSidebar getTitle & getDescription
Hello,
It's not possible, to use dynamic closure on the label attribute of PageNavigationItem.
Calling the parent method, to benefit of
evaluate
method (NavigationItem::getLabel).By the way, maybe evaluate can be used for isHiddenWhen ?