Allow 'link text' without 'URL' (URL optional)

Created on 23 May 2017, over 8 years ago
Updated 31 January 2025, 8 months ago

In drupal 7 you had the ability to make the URL field optional, this seems to have been removed for drupal 8.

It does seem possible at the moment: when you configure the link field with an "Allow link text: *required".
You should be able to just fill the "link text" field without an URL. But when you save this node, it empties the 'link text' field, you have to put in an url to be able to show the text. That's why it looks like a bug to me at the moment, but maybe this was made intentional?

Use case:

  • A simple "subtitle" field that should link to internal or external content on specific pages. This would be easily made if the URL part was optional.

Proposed solutions:

  • make the URL field optional (make it work like Drupal7 link)
  • if this is not possible, perhaps a token ? this would be the worse option.
✨ Feature request
Status

Active

Version

11.0 πŸ”₯

Component

link.module

Created by

πŸ‡³πŸ‡±Netherlands bskibinski Breda, The Netherlands

Live updates comments and jobs are added and updated live.
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.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Just ran into this and can confirm it would be super helpful for some edge-cases. I know this is called link-field but the flexibility bonus would really help.

    Another real-world example: We have a "License information" link field. In 90% of the cases this uses a URL and a description, but in some cases there just IS no source URL and so the author should be allowed to leave out the URL. It would be great, if the maintainers would accept this request.

    For sure this is not a bug ;) It's a feature request.

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

    It looks like a validation function that blocks submission of link text only was added a while back in #2923496. I'm going to try combining the technique mentioned in #25 with a composer patch that disables that validation function to see if I can get this working again.

  • πŸ‡ΊπŸ‡ΈUnited States attheshow
  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    Then I think this should be added as description for the link URL fields, at least in the admin UI, but perhaps also in the user UI?
    Otherwise nobody will see it and we land here ... Reopening the issue for that documentation. Maybe someone has some minutes to create a MR?

  • Looks like the description for <nolink> is already present on the link field.

  • πŸ‡©πŸ‡ͺGermany Anybody Porta Westfalica

    @riyas_nr thanks - strange, maybe it wasn't in the past so we didn't see it... back to WAD.

Production build 0.71.5 2024