I'm trying to create a custom webform handler. I'd like to be able to attach my handler to any webform and have it display the message 'xyz' when the (multi step wizard) form is finally submitted. I have this file in my custom module at: my_module/src/Plugin/WebformHandler/PostWebformHandler.php
.
<?php
namespace Drupal\test_b\Plugin\WebformHandler;
use Drupal\webform\Plugin\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;
/**
* Webform test b handler.
*
* @WebformHandler(
* id = "test_b",
* label = @Translation("Test B"),
* category = @Translation("Test B"),
* description = @Translation("Test B webform submission handler."),
* cardinality = \Drupal\webform\Plugin\WebformHandlerInterface::CARDINALITY_UNLIMITED,
* results = \Drupal\webform\Plugin\WebformHandlerInterface::RESULTS_PROCESSED,
* submission = \Drupal\webform\Plugin\WebformHandlerInterface::SUBMISSION_OPTIONAL,
* )
*/
class TestBWebformHandler extends WebformHandlerBase {
/**
* {@inheritdoc}
*/
public function preSave(WebformSubmissionInterface $webform_submission) {
\Drupal::messenger()->addMessage(t('xyz'));
}
}
On navigating to my Webform settings, I see:
but when I click Add handler for Test B it does not attach to my form handlers?