Add the ability to set the type of message used for closed messaging

Created on 26 January 2024, 10 months ago
Updated 28 March 2024, 8 months ago

Problem/Motivation

At the moment if a webform is closed, then the message displayed to the user will be set as a status message. I'd like the ability to have it styled as either an error or a warning please.

Steps to reproduce

View a webform that's closed.

Proposed resolution

Add additional options that allow selecting how the message should be classified.

Remaining tasks

Decide if this is a good idea, and code it up :)

User interface changes

Webform editors will get the ability to select the type of message added.

API changes

None.

Data model changes

Additional configuration entries will be added for the message type, alongside the text.

✨ Feature request
Status

Closed: won't fix

Version

6.2

Component

Code

Created by

πŸ‡¬πŸ‡§United Kingdom steven jones

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

Comments & Activities

  • Issue created by @steven jones
  • Status changed to Closed: won't fix 10 months ago
  • πŸ‡ΊπŸ‡ΈUnited States jrockowitz Brooklyn, NY

    New features should be handled in a dedicated contribute module or custom code.

  • πŸ‡¬πŸ‡§United Kingdom steven jones

    @jrockowitz oh, that's news to me! Is webform no longer being enhanced then? Is it bug fixes only?

    Would you accept a patch that provides this extension to webforms currently closed messaging functionality at all? (I'm fairly happy to write one!)

  • πŸ‡¬πŸ‡§United Kingdom altcom_neil

    Hi, we have had exactly the same problem with the closed message having the wrong message type 'status' instead of 'type'.

    Attached is patch that adds a config "Message Type overrides" in the Webforms: Advanced configuration > User interface settings.

        $form['ui']['message_types'] = [
          '#type' => 'webform_codemirror',
          '#mode' => 'yaml',
          '#title' => $this->t('Message Type overrides'),
          '#description' => $this->t('Override the message types from their default values in code. Use Yaml, one per line e.g. <code>form_close_message: warning

    '),
    '#default_value' => $config->get('ui.message_types'),
    ];

    In Drupal\webform\WebformMessageManager::apply Drupal\webform\WebformMessageManager::display the config is then retrieved and allows you to replace the hardcoded message type:

          $webform_message_types = Yaml::decode($this->configFactory->get('webform.settings')->get('ui.message_types') ?: '') ?: [];
          if (!empty($webform_message_types[$key])) {
            $type = $webform_message_types[$key];
          }
    
Production build 0.71.5 2024