public function ExampleWebformVariant::applyVariant in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_example_variant/src/Plugin/WebformVariant/ExampleWebformVariant.php \Drupal\webform_example_variant\Plugin\WebformVariant\ExampleWebformVariant::applyVariant()
Apply variant to the webform.
Return value
bool TRUE if this variant was applied to the webform.
Overrides WebformVariantBase::applyVariant
File
- modules/
webform_example_variant/ src/ Plugin/ WebformVariant/ ExampleWebformVariant.php, line 94
Class
- ExampleWebformVariant
- Webform example variant.
Namespace
Drupal\webform_example_variant\Plugin\WebformVariantCode
public function applyVariant() {
$webform = $this
->getWebform();
if (!$this
->isApplicable($webform)) {
return FALSE;
}
// Set description markup.
$description_markup = $this->configuration['description__markup'];
$description_element = $webform
->getElementDecoded('description');
if ($description_element && $description_markup) {
$description_element['#markup'] = $description_markup;
$webform
->setElementProperties('description', $description_element);
}
// Set notes type.
$notes_type = $this->configuration['notes__type'];
$notes_element = $webform
->getElementDecoded('notes');
if ($notes_element && $notes_type) {
$notes_element['#type'] = $notes_type;
$webform
->setElementProperties('notes', $notes_element);
}
return TRUE;
}