Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Token in field descriptions not working unless in fields that handle multiple values #6196

Closed
indigoxela opened this issue Aug 8, 2023 · 7 comments · Fixed by backdrop/backdrop#4495

Comments

@indigoxela
Copy link
Member

indigoxela commented Aug 8, 2023

Description of the bug

Tokens in field descriptions (on node form) aren't replaced in several field types.

Steps To Reproduce

  1. Add fields of types that do not handle multiple values on their own (like text) to content type
  2. Add a description (help text) to that field via field UI (on /admin/structure/types/manage/TYPE/fields/field_FIELD)
  3. Note that every field type has that token browser available
  4. Use tokens from the token browser on that admin form (date or whatever)
  5. Save the field instance
  6. Now create a new node of that type (/node/add/TYPE)

Actual behavior

The tokens are there plain text, no replacement, unless it's a field widget that handles multiple values, like the file or image field.

widget-token

Expected behavior

As the token browser is available, I'd also expect the tokens to get replaced.

Additional information

  • Backdrop CMS version: latest dev
  • PHP version: 8.1

The token handling came into core with #480, but the only place function token_replace() is used is here, which means, only when some conditions are met. NOT in field_multiple_value_form(), which runs on most field types.

@indigoxela
Copy link
Member Author

A PR is available for testing and review.

BTW, another option would be to remove the token browser from fields, that use the multi-value form, but that doesn't seem logical to me. 😉

@argiepiano
Copy link

@indigoxela thank you for providing this PR. It doesn't fix all situations. If you add an image field with single cardinality, the token is still not replaced.

@argiepiano
Copy link

The issue is in theme_file_upload_help() where $descriptions uses the original widget help text without replacing tokens. The solution is to do a token_replace in line 273.

@indigoxela
Copy link
Member Author

@argiepiano seems like our brains are perfectly in sync. 😆 I just came to the same conclusion and pushed another commit to fix single value image fields.

@argiepiano
Copy link

In the meantime I've found that Paragraphs has the same problem in paragraphs_field_multiple_value_form() and will file an issue there.

@argiepiano
Copy link

Tested and reviews, RTBC!

@laryn
Copy link
Contributor

laryn commented Sep 15, 2023

Thank you @indigoxela and @argiepiano -- merged into 1.x and 1.25.x.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants