"Setting not found" not always desired

Created on 8 June 2020, about 4 years ago
Updated 15 September 2023, 10 months ago

Right now when a site setting is not created the tokens return "Setting not found". Could we consider returning nothing so the token can be used in conditional fields or other areas where the string might not be desired? I could provide a patch that removes the

else {
  return t('Setting not found');
}

from _site_settings_retrieve_deep_value but not sure if you'd like to keep it for backwards compatibility or not.

✨ Feature request
Status

Fixed

Version

1.19

Component

Code

Created by

πŸ‡¨πŸ‡¦Canada pavlosdan

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

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • πŸ‡ͺπŸ‡¨Ecuador jwilson3

    I was able to achieve what I needed with a small snippet of code, but it is definitely a bit hacky:

    // In settings.php
    $settings['locale_custom_strings_en'][''] = [
      // Ensure settings that are intentionally left empty are not rendered.
      'Setting not found' => '',
    ];
    

    If this were to go in, I would want a bit more context in the alter hook, to be honest:

    1. to customize the empty token string value on a per-setting basis, ie, pass an argument to the alter hook with the site setting entity machine name.
    2. to customize the empty token string value on a field type and/or field name, and or site setting group basis, so that a fallback value could be specified appropriately in different cases; i.e. pass an argument to the alter hook with the token name being substituted.
    3. to customize the empty token string value using the default value specified in the field definition; ie pass an argument to the alter hook with the field definition. (I guess technically this could be loaded based by exploding the token name and loading the field name, so not required but definitely nice to have).
  • Status changed to Fixed 10 months ago
  • πŸ‡¬πŸ‡§United Kingdom scott_euser

    Thanks!

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

Production build 0.69.0 2024