pier
Conditional widget based on RelationManager
I've found a solution. I don't know if it's the best way, but it works. If you want to conditionally show widgets on the View page, you can access the public property activeRelationManager from the HasRelationManagers trait. Then, you can populate the widget array in the getHeaderWidgets function. In your case, it could be like this:
protected function getHeaderWidgets(): array
{
$activeRelationManager = $this->activeRelationManager ?? "0";
$widgets = [];
if($activeRelationManager === "0") { // first tab
$widgets[] = ProposalResource\Widgets\ProposalOverview::class;
}
return $widgets;
}
3 replies