Problem/Motivation

Currently, everything else on a webform can be overridden with exception to the title and description. This is something that is needed as sites might create variants that should have different title and description based on conditions like domain or language, etc.

Steps to reproduce

Add a new webform variant that overrides the title and description. In `buildConfigurationForm()`

    $form['overrides']['title'] = [
      '#type' => 'textfield',
      '#title' => $this->t('Title'),
      '#description' => $this->t('Enter the overridden title of the webform.'),
      '#default_value' => $this->configuration['title'] ?? NULL,
      '#weight' => -10,
    ];

    $form['overrides']['description'] = [
      '#type' => 'textarea',
      '#title' => $this->t('Description'),
      '#description' => $this->t('Enter the overridden description of the webform.'),
      '#default_value' => $this->configuration['description'] ?? NULL,
      '#weight' => -5,
    ];

In `submitConfigurationForm()`:

    $this->configuration['title'] = $this->configuration['overrides']['title'];
    $this->configuration['description'] = $this->configuration['overrides']['description'];

Proposed resolution

Alter `applyVariant()` function to override the title and description if an override exists for the variant.

Issue fork webform-3504274

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

shabana.navas created an issue. See original summary.

shabana.navas’s picture

Version: 8.x-5.x-dev » 6.x-dev
shabana.navas’s picture

Status: Active » Needs review
StatusFileSize
new1.9 KB
shabana.navas’s picture

StatusFileSize
new3.47 KB

Adding tests.

liam morland’s picture

Status: Needs review » Needs work

Thanks for the patch. Please put it in an issue fork and merge request.

jrockowitz’s picture

Version: 6.x-dev » 6.3.x-dev
jrockowitz’s picture

Status: Needs work » Needs review

The title and description are properties on the webform, and we should add the ability to override webform properties.

I don't see why anyone would override the description because it is never visible. I do see people wanting to override title, css, and javascript using a variant.

I am seeing config schema validation issues that may be unrelated to this change. I figured out the config schema issue.

jrockowitz’s picture

Status: Needs review » Reviewed & tested by the community

RTBC if tests pass

  • jrockowitz committed ed35905e on 6.3.x
    [#3504274] feat: Variants do not override the title and description
    
    By...
jrockowitz’s picture

Status: Reviewed & tested by the community » Fixed

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

  • jrockowitz committed ed35905e on 6.x
    [#3504274] feat: Variants do not override the title and description
    
    By...

Status: Fixed » Closed (fixed)

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