Mix your own tabs with relation manager tabs

Mix your own tabs with relation manager tabs

  • resource
  • relation manager
  • tabs
PR #20734 by @danharrin

On Edit and View pages that show the form and relation managers as tabs, you can now choose which tabs appear and in what order, including your own custom tabs between relation managers. Override getCombinedTabComponents(), return a keyed array of tabs, and call getRelationManagerTabComponent('key') wherever a relation manager should go. The empty key '' is still the main form tab. Tab order now follows the array, not getContentTabPosition().

Say a Post edit page should show an Overview tab first, then Comments, then the form (renamed "Edit"), then Tags:

public function getCombinedTabComponents(): array
{
  return [
     'overview' => Tab::make('Overview')->schema([/* ... */]),
     'comments' => $this->getRelationManagerTabComponent('comments'),
     '' => $this->getContentTabComponent()->label('Edit'),
     'tags' => $this->getRelationManagerTabComponent('tags'),
  ];
}

The relation manager keys come from getRelations() and show up in the URL, like ?relation=overview. Relation managers the user can't access are left out automatically. $tabs + this->getRelationManagerTabComponents(except:arraykeys(tabs)) adds any you haven't placed.

All Filament Up To Date tips