Links to pages
An action can open a page instead of running a handler. It has no handler and never reaches the server; the link is rendered with the page.
// A page of an external system of Config\Anvil::$linksAction::make('openHr') ->label('Open in HR')->icon('box-arrow-up-right')->inRow() ->permission('people.view') ->link('hr', '{value}', fn ($person) => $person['personnel_number']),
// A page of the applicationAction::make('contact') ->label('Contact')->icon('person')->inRow() ->permission('contacts.view') ->url(fn ($deal) => $this->panel()->resource('contacts')?->path('view', $deal['contact_uuid'])),link()
Section titled “link()”link(system, path, value, target) builds the address from a configured
system: {value} in the path is replaced by the encoded result of the
closure. Systems, https, targets and noopener work exactly like for
columns, see Links.
url(path, target) opens a path of the application (/…) or an
http(s) URL returned by the closure; other schemes such as
javascript: are rejected.
- Targets:
Link::SAME(_self),Link::NEW(_blank) or a tab name. Internal links open in the same tab by default, external ones in a new tab. - If the closure returns
nullor an empty string, the action is not shown for that record. - Link actions are not offered in the API.