Adding custom attribute controlled through multiple form elements

Created on 15 January 2024, 11 months ago

Problem/Motivation

This is a follow-up issue of ✨ Add the "download" Attribute to force download the link target (PDF, Images, ...) Closed: won't fix .

The "download" attribute (https://www.w3schools.com/tags/att_a_download.asp) has a unique functionality, that only if it has no value, it will use the value of the file to download. If it is set to "download" (download="download") the file you download will be renamed to "download". Leaving the value empty wouldn't make sense, as that generally implies there shouldn't be a download attribute on the link field.

The best approach would be to combine two form elements to control the attribute: An "Enable download attribute" checkbox and A simple text field.
This way, you could enable the download attribute via checkbox, but leave the attribute value empty, so it will still be applied to the link, just without value.

How would we approach something like this? Would this be a helpful feature for the maintainers?

The current implementation can be seen here:
https://git.drupalcode.org/project/link_attributes_bonus/-/blob/1.x/link...
But the problem is, that it does not allow for the regular use of the download attribute (with empty value for auto-filename generation)!

Steps to reproduce

Proposed resolution

Implement the option, to have multiple form elements control one attribute.

Remaining tasks

User interface changes

API changes

Data model changes

✨ Feature request
Status

Active

Version

2.0

Component

Code

Created by

πŸ‡©πŸ‡ͺGermany Grevil

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Production build 0.71.5 2024