[6.x] Add support for custom link types#15004
Open
duncanmcclean wants to merge 12 commits into
Open
Conversation
…eldtype Previously every registered link type in Bard was routed through a hardcoded relationship input (or a bespoke asset selector), so custom link types with a non-relationship picker never actually worked in Bard. Now Bard dynamically renders each type's own fieldtype component, same as the Link fieldtype already does. Guard against CollectionNotFoundException since linkTypesForToolbar now eagerly preloads every visible type on every Bard field render, which would otherwise crash on installs with no collections yet.
Link::extend() appends config fields onto Fieldtype's shared static, which was leaking into later tests.
Matches the Link fieldtype's behavior of opening the selector immediately when switching to a type with nothing selected yet.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This pull request implements support for registering custom link types on the Link fieldtype, and unifies Bard's link button to use the same system.
Previously, the Link fieldtype only supported linking to a URL, Entry, Asset, or (in a collection with a structure) the first child page. There was no way for addons, like Runway and Forms Pro to add their own link types.
Addons can now register a link type from their service provider:
A
LinkTypecontrols how the type is displayed, how a stored value resolves back to a real link, and what fieldtype powers its picker:Once registered, the Link fieldtype will show the link type in the dropdown and render a picker using the provided fieldtype.
This PR also migrates the native Entry and Asset options onto the same
LinkTypesystem, so there's a single code path for native and third-party types alike.Bard
Bard's link button previously had its own, entirely separate implementation for resolving
entry::/asset::references (viastatamic://URIs and theDatarepository) and its own hardcoded Entry/Asset picker.This PR unifies it onto the same
Link::extend()registry — any custom link type registered for theLinkfieldtype is now automatically available in Bard's link button too, with no extra wiring needed.Closes statamic/ideas#1181
Docs: statamic/docs#1949