Closed (fixed)
Project:
Custom Tokens
Version:
8.x-1.x-dev
Component:
Code
Priority:
Minor
Category:
Feature request
Assigned:
Unassigned
Reporter:
Created:
15 Feb 2025 at 15:34 UTC
Updated:
31 Jan 2026 at 06:32 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
macsim commentedComment #3
anybody@macsim feel free to prepare a MR with that functionality or solve it in contrib / custom. Seems a very edge-case?
Comment #4
longwaveThis would actually be useful to me as I have a set of tokens that should only be plain text, for now I've worked around it with a form alter hook.
Comment #5
anybodyWouldn't contrib https://www.drupal.org/project/allowed_formats fix this? Has someone tried?
I still think this might be an edge-case for which https://www.drupal.org/project/allowed_formats has been made?
Comment #6
longwaveAllowed formats is in core now, but as far as I can see it only works for configurable fields, and the
contentfield on a custom token is a base field.I tried adding
to the TokenCustom entity type annotation, which exposes Field UI on the token custom type edit form and allows you to add new fields to custom token bundles, and even change the widget for the
contentfield, but as far as I can see there is no way of editing the settings of thecontentfield itself.Comment #7
anybodySorry @longwave you're right! I thought it was a "body" field.
So maybe it's somehow related to #2353867: [META] Expose Title and other base fields in Manage Display or we could alternatively change the content into a real richt text field?
Comment #8
longwavehttps://www.drupal.org/project/base_field_override_ui works! If I make the change in #6 and enable Base Field Override UI then the content field settings can be overridden:
Will open an MR for the Field UI change, I think that's all that needs to happen.
Comment #10
longwaveComment #11
anybodyWhao, nice catch @longwave! Any risks of side-effects you see? Otherwise this LGTM and I'd be fine to merge this!
Comment #12
longwaveI don't think so.. I mean I am not sure it is much use allowing the rest of field UI here - what does it mean to add additional fields to a custom token? - but otherwise everything seems to work fine. Perhaps someone has some use for custom fields on a token somewhere...
Comment #13
anybodyOk I also can't see risks, so let's do it :)
Comment #14
anybodyLet's keep it in dev for a while... @macsim please give it a try!
Comment #15
anybodyComment #18
macsim commentedSorry guys it's been a long time I didn't came here.
Just gave a try to that solution using Token custom 8.x-1.x-dev + Base Field Override UI 8.x-1.2 on a Drupal 11.3 and it works like a charm - thanks @longwave for the tip and merge request.
I am now able to choose which formats are allowed on a given custom token type :)
@anybody with all my due respect, usually the reporter should also be in the contribution records
Comment #19
anybodyThanks for the feedback @macsim.
Regarding your comment for the contribution record... well I don't see a problem granting you the credits and don't want to be stingy with you, but it's just a feature request in one sentence, so I think the community served you and not the other way around?
Please don't take this personally or anything, I mean this totally objective. If you provided a first MR, patch or at least the key solution, I would definitely have done so...
If @longwave thinks my decision was wrong here, please correct me.
I absolutely don't want to be unfair!
Comment #20
macsim commentedHonestly, I don't mind ; it was just an idea to improve the module. I am glad I was not alone who thought it would have been necessary to limit certain types of custom tokens to plain text (or any other text format), and happier the feature has been implemented even if we have to install another module to reach the goal.
Don't worry, I don't take it personally :-) I just see things differently: by creating the feature request, the reporter - even if he didn't made a MR / patch / review / or propose a solution - is the first entrypoint to that improvment that's why I usually give him credit as well.
I'll do more next time ;-)
Thanks again @longwave
Comment #21
anybodyAs written I didnt want to be stingy and you're still active here and tested the result, so let's do it. I granted you credit.
Thanks for taking the time for reply @macsim, I hope you understand my point. Let's just keep pushing Drupal and open source together :)