Allow module to alter the $settings_additional values

Created on 18 May 2021, over 3 years ago
Updated 22 August 2024, 5 months ago

Problem/Motivation

There is currently no way to alter the $settings_additional array values. For example, if you need to change the 'anyLabel' to something other than '- Any -' there currently is no way.

Proposed resolution

Implement an alter call handler to allow other modules to alter the values.

API changes

With the attached patch module can use the sample code below to alter the setting values:

function MY_MODULE_shs_alter(&$settings_additional) {
  $settings_additional['anyLabel'] = ' -select -';
}

Feature request
Status

Active

Component

Code

Created by

🇺🇸United States 3cwebdev

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.

  • 🇺🇸United States rpayanm

    You can do it using this hook:
    https://git.drupalcode.org/project/shs/-/blob/2.0.x/src/Plugin/views/fil...

    $hooks = [
        'shs_js_settings',
        "shs_{$field_name}_js_settings",
        "shs_{$this->view->id()}__{$identifier}_js_settings",
        "shs_{$this->view->id()}__{$field_name}_js_settings",
        "shs_{$this->view->id()}__{$this->view->current_display}__{$identifier}_js_settings",
        "shs_{$this->view->id()}__{$this->view->current_display}__{$field_name}_js_settings",
      ];
      // Allow other modules to override the settings.
     \Drupal::moduleHandler()->alter($hooks, $settings_shs, $bundle, $field_name);
    
  • 🇫🇮Finland heikkiy Oulu

    I was able to solve the problem with the instructions from #3. I think this issue could be closed and perhaps document this in the module readme.txt.

Production build 0.71.5 2024