Leverage new #type 'item' for Link field formatter (merge 'link_separate' formatter into 'link_default')

Created on 16 December 2012, about 12 years ago
Updated 23 January 2025, about 1 month ago

Follow-up to: #1829202: Make #type 'item' work outside of a form context to render a compound label + content β†’

Problem

  • Link module has to implement a second field formatter, because there is no way to render a compound element with a #title and #markup.

Goal

  • Eliminate Link module's 'link_separate' field formatter (merge it into 'link_default').

Details

  • The Link field ships with two formatters: 'link_default' and 'link_separate'.
  • The difference is that the 'separate' formatter outputs the link title and link URL as separate HTML elements. To clarify:

    Output of 'link_default':

    <a href="http://example.com">My link title</a>
    

    Output of 'link_separate':

    <h4>My link title</h4>
    <a href="http://example.com">http://example.com</a>
    
  • Both formatters share most of the settings to control whether to output the URL as plain-text (instead of a link) and so on. Also, the code to sanitize the values as well as applying tokens is almost identical.
  • I don't know what our current guidelines are with regard to "When, exactly, does one implement a standalone formatter instead of formatter settings?"

    In other words, is a formatter defined by its technical behavior? Or is it defined by its resulting markup?

    Because, if it's the markup that makes up a formatter, then the 'separate' formatter definitely produces different markup and should probably stay its own formatter... But if the markup does not play a key role - or if the marginal difference outlined above is not deemed to be sufficient - then it would be OK to merge them.

πŸ“Œ Task
Status

Postponed: needs info

Version

11.0 πŸ”₯

Component

link.module

Created by

πŸ‡©πŸ‡ͺGermany sun Karlsruhe

Live updates comments and jobs are added and updated live.
  • API clean-up

    Refactors an existing API or subsystem for consistency, performance, modularization, flexibility, third-party integration, etc. May imply an API change. Frequently used during the Code Slush phase of the release cycle.

Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ΊπŸ‡ΈUnited States smustgrave

    Thank you for creating this issue to improve Drupal.

    We are working to decide if this task is still relevant to a currently supported version of Drupal. There hasn't been any discussion here for over 8 years which suggests that this has either been implemented or is no longer relevant. Your thoughts on this will allow a decision to be made.

    Since we need more information to move forward with this issue, the status is now Postponed (maintainer needs more info). If we don't receive additional information to help with the issue, it may be closed after three months.

Production build 0.71.5 2024