AI Interpolator settings form shows enable token hint only if token module is enabled

Created on 9 July 2024, 5 months ago

Problem/Motivation

While going through the steps in this video Deep crawling using AI Interpolator[https://www.youtube.com/watch?v=5bcdfsNkaVs] I wanted it to select the advanced mode option.

But I was shown a different settings form as in the video, I then remembered that the video briefly mentioned de token module. I then went to look in the form's code, because I would expect to see help text indicating "token must be enabled to use this".

This is added to the code only this description is in an if, that only shows this description if the module is already enabled, which somewhat defeats the purpose of the text.

 if ($this->moduleHandler->moduleExists('token')) {
      $form['interpolator_container']['interpolator_mode'] = [
        '#type' => 'select',
        '#title' => $this->t('Interpolator Input Mode'),
        '#description' => $this->t('If you have token installed you can use it in advanced mode, otherwise it uses base mode.'),
        '#options' => $modeOptions,
        '#default_value' => $fieldInfo->getThirdPartySetting('ai_interpolator', 'interpolator_mode', 'base'),
        '#weight' => 5,
        '#attributes' => [
          'name' => 'interpolator_mode',
        ],
      ];
    }
    else {
      $form['interpolator_container']['interpolator_mode'] = [
        '#value' => 'base',
      ];
    }

Steps to reproduce

Install and enable the AI Interpolator module without enabeling the token module.

When enabeling AI Interpolator on a text field, this description is shown under Interpolator Base Field:

"This is the field that will be used as context field for generating data into this field."

Proposed resolution

I would add a part to this text so that in both cases it is mentioned for advanced mode to have to enable the token module.

E.g. "This is the field that will be used as context field for generating data into this field. If you want to use advanced mode, the token module must be enabled."

Remaining tasks

Decide how best to solve this problem, modify the code, create an MR, review MR and merge if correct.

User interface changes

Some extra text will be added to the settings from.

🐛 Bug report
Status

Active

Version

1.0

Component

Code

Created by

🇧🇪Belgium dtfabio Ninove

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

Comments & Activities

Production build 0.71.5 2024