Problem/Motivation
Some media types have field_copyright to enter copyright information. We used a link field, because it seemed the best solution to enter a link or a text or both.
Sadly we later saw that when entering a text, the URL becomes required* (probably by form states api).
So we should please check if we can remove this requirement just for this fields in media entities or if there are any risky technical reasons.
Steps to reproduce
Proposed resolution
Remaining tasks
User interface changes
API changes
Data model changes
| Comment | File | Size | Author |
|---|---|---|---|
| #11 | screenshot-2026-03-23 09_24_23.png | 44.48 KB | grevil |
| #10 | screenshot-2026-03-23 09_14_40.png | 7.52 KB | grevil |
Issue fork drowl_media-3580028
Show commands
Start within a Git clone of the project using the version control instructions.
Or, if you do not have SSH keys set up on git.drupalcode.org:
Comments
Comment #2
anybodyComment #3
thomas.frobieterAfter reading through #2880632: Allow 'link text' without 'URL' (URL optional), I found that there isn't a single compelling argument against making the URL field optional, so editors are not required to type "
<nolink>" every single time.Thankfully, the solution has also been posted: https://www.drupal.org/project/drupal/issues/2880632#comment-14954104.
@grevil could you please implement this for media.field_copyright?
Comment #5
grevil commentedDone! Works as expected. Already tested locally in my tt environment!
Please review.
Comment #7
grevil commentedUnfortunately some auto-formatting was done here, I hope you don't mind.
Comment #8
anybody@grevil thanks, looks good so far, but maybe the unset is enough?
See https://www.drupal.org/project/drupal/issues/2880632#comment-14954104
Or are we sure we need to remove the additional validation? I'd just like to have the change as simple as possible, but if it's needed that's also fine!
One more point I think we should add, otherwise we might wonder later: Should we add a sentence to the description like:
+ "Entering only a license text with no link is also supported."
That might make it easier to find the root of changes?
Comment #9
grevil commentedYes, 100% otherwise we can't save the form.
SGTM!
Comment #10
grevil commentedFYI, here is the validation error, when only the text is given and no url:

(States already removed)
Comment #11
grevil commentedUnfortunately, the text already has quite the description. So I added the string to the URL. How about that?

Comment #12
grevil commentedRemoved the "Optional".
Comment #14
anybodyThanks, merged!
@thomas.frobieter can you tag a new release?
Comment #15
anybodyComment #17
anybody@thomas.frobieter: PS: Do we need to cherry-pick this into 4.x also?
Comment #18
thomas.frobieterYes, I think so
Comment #19
anybody@thomas.frobieter okay I created a MR here: https://git.drupalcode.org/project/drowl_media/-/merge_requests/54/diffs
Looks like 4.x is the same in this file and this should be good to go?
Comment #20
anybodyComment #22
thomas.frobieterComment #24
grevil commentedApparently, this didn't fix anything, but now the text will just be cleared.
Comment #25
anybodyWell it fixed the required, but introduced this bug :D
If there's no clean solution, we could maybe fill the link with
<nolink>right before safe if empty, see https://www.drupal.org/project/drupal/issues/2880632#comment-16218953Comment #26
grevil commentedYea I originally tried it with the nolink, but it threw an invalid url exception...
Comment #29
grevil commentedOk, this works now. NOTE, that the field needs to allow both internal AND external links, as "" is seen as an internal link for some reason.
Please review @anybody.
Comment #30
anybody@grevil:
Then we can remove the workaround? That would be better!
It's quite risky if the field is misconfigured, so can we check the value and show an error message or something like that, instead of our logic?
The setting for both seems to be:
(was 16 for only external links)
Comment #31
grevil commentedSorry, I meant
<nolink>not an empty string "".If the field is accidentally set to "allow external urls only", the form will automatically throw a validation error, because
<nolink>is seen as an internal link. Should be good to go!Comment #32
anybodyOk nice, RTBC!
Comment #34
anybodyPlease cherry-pick (with MR) into 4.x!
Comment #37
grevil commented