Custom Fields for the Link fieldtype
Nobody has claimed this yet.
- Dominant language
- PHP
- Stars
- 3.6k
- Forks
- 705
- Avg merge
- 1d 5h
- Merged PRs (30d)
- 134
Description
With Craft as dependent as it is on custom fields, it seems a bit incongruous to have the advanced fields of the Link fieldtype be a limited assortment of "hard-coded" options. I mean, what you do have absolutely does make sense, it just begs the question of why there isn't a "custom field" type of option.
IRL use cases for custom fields on links:
- Link style: Many times, a client will want to have the option to show a link in a button-style, rather than a "text link" style. It would simplify things if us developers could provide a dropdown field to select that on the link itself.
- Progressive enhancement: A link which goes to a "utility" page of some sort (login/register/search/subscribe/etc) by default, but if JS is enabled, the functionality of those pages gets loaded into a
<dialog>instead. - Marketing: Typically it's more user-friendly to allow content authors to add marketing URL params in a visual manner instead of a technical one. Having them type out "?ref=campaign_name" in the URL suffix field is a technical approach; allowing them to select (via a Relationship field) the associated Campaign entry is a visual approach.
Taken to the "extreme", perhaps links could benefit from being Entry Types themselves?
Originally posted by @Michael-Paragonn in https://github.com/craftcms/cms/issues/16268#issuecomment-2559004026
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Link fieldtype entry point and review how its current advanced fields are defined. Compare the requested custom link fields and possible Entry Type approach, then define a focused scope and acceptance criteria for supporting author-defined link metadata.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- php
- Domain
- backend, content
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100