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.


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) {


On navigating to my Webform settings, I see:

enter image description here

but when I click Add handler for Test B it does not attach to my form handlers?

enter image description here

  • 1
    The file and class names don't match (they need to)
    – Clive
    Nov 23, 2018 at 13:38

1 Answer 1


The above code works. My mistake was in the naming of things. Name all files, classes etc. foo and it will attach.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.