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

Command icon 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

anybody created an issue. See original summary.

anybody’s picture

Title: Allow entering only text in the copyright link field » Allow entering *only text* in the copyright link field
thomas.frobieter’s picture

Assigned: thomas.frobieter » grevil

After 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?

grevil made their first commit to this issue’s fork.

grevil’s picture

Assigned: grevil » Unassigned
Status: Active » Needs review

Done! Works as expected. Already tested locally in my tt environment!

Please review.

grevil’s picture

Unfortunately some auto-formatting was done here, I hope you don't mind.

anybody’s picture

Status: Needs review » Needs work

@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?

grevil’s picture

Or are we sure we need to remove the additional validation

Yes, 100% otherwise we can't save the form.

add a sentence to the description like:
+ "Entering only a license text with no link is also supported."

SGTM!

grevil’s picture

StatusFileSize
new7.52 KB

FYI, here is the validation error, when only the text is given and no url:
screenshot
(States already removed)

grevil’s picture

Status: Needs work » Needs review
StatusFileSize
new44.48 KB

dd a sentence to the description like:
+ "Entering only a license text with no link is also supported."

Unfortunately, the text already has quite the description. So I added the string to the URL. How about that?
screenshot2

grevil’s picture

Removed the "Optional".

  • anybody committed 62e0cfe7 on 5.x authored by grevil
    feat: #3580028 Allow entering *only text* in the copyright link field
    
anybody’s picture

Status: Needs review » Reviewed & tested by the community

Thanks, merged!

@thomas.frobieter can you tag a new release?

anybody’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

anybody’s picture

@thomas.frobieter: PS: Do we need to cherry-pick this into 4.x also?

thomas.frobieter’s picture

Yes, I think so

anybody’s picture

Version: 5.x-dev » 4.x-dev
Status: Fixed » Active

@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?

anybody’s picture

Assigned: Unassigned » thomas.frobieter
Status: Active » Needs review

thomas.frobieter’s picture

Status: Needs review » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

grevil’s picture

Version: 4.x-dev » 5.x-dev
Status: Fixed » Active

Apparently, this didn't fix anything, but now the text will just be cleared.

anybody’s picture

Assigned: thomas.frobieter » grevil
Status: Active » Needs work

Well 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-16218953

grevil’s picture

Yea I originally tried it with the nolink, but it threw an invalid url exception...

grevil changed the visibility of the branch 3580028-allow-entering-only to hidden.

grevil’s picture

Assigned: grevil » anybody
Status: Needs work » Needs review

Ok, 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.

anybody’s picture

Status: Needs review » Needs work

@grevil:

Ok, 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.

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:

settings:
  link_type: 17

(was 16 for only external links)

grevil’s picture

Assigned: anybody » Unassigned
Status: Needs work » Needs review

Sorry, 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!

anybody’s picture

Status: Needs review » Reviewed & tested by the community

Ok nice, RTBC!

  • anybody committed b0ca77de on 5.x authored by grevil
    Related to #3580028: Set <nolink> to not clear text
    
anybody’s picture

Please cherry-pick (with MR) into 4.x!

  • grevil committed ae5240af on 4.x
    Related to #3580028: Set <nolink> to not clear text
    
    
    (cherry picked...

  • grevil committed ae5240af on cherry-pick-b0ca77de
    Related to #3580028: Set <nolink> to not clear text
    
    
    (cherry picked...
grevil’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.