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.
| Comment | File | Size | Author |
|---|---|---|---|
| #4 | webform-3504274-4.patch | 3.47 KB | shabana.navas |
Issue fork webform-3504274
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
Comment #2
shabana.navas commentedComment #3
shabana.navas commentedComment #4
shabana.navas commentedAdding tests.
Comment #5
liam morlandThanks for the patch. Please put it in an issue fork and merge request.
Comment #6
jrockowitz commentedComment #7
jrockowitz commentedThe 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.Comment #9
jrockowitz commentedRTBC if tests pass
Comment #11
jrockowitz commented