Commit 0100dafc authored by Liam Morland's avatar Liam Morland
Browse files

ISTWCMS-4881: Add a Webform CAPTCHA component to each newly-created Webform

parent a51a35de
......@@ -5,6 +5,7 @@
* Workbench module file.
*/
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Form\FormStateInterface;
use Drupal\menu_link_content\Entity\MenuLinkContent;
......@@ -126,3 +127,18 @@ function uw_sites_all_update_projects_alter(&$projects) {
$project['info']['version'] = preg_replace('/-uw_wcms\d*$/', '', $project['info']['version']);
}
}
/**
* Implements hook_ENTITY_TYPE_presave().
*/
function uw_sites_all_webform_presave(EntityInterface $webform): void {
// Add a Webform CAPTCHA component to each newly-created Webform.
if ($webform->isNew()) {
$elements = [
'captcha' => [
'#type' => 'captcha',
],
];
$webform->setElements($elements);
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment