Webform submitForm hook

by Ronnie   Last Updated December 12, 2017 19:07 PM

I am using drupal 8 and webform 8.x-5.0-beta25. I have a multistep form with ajax enabled, 5 pages.

I need to alter the confirmation message but I haven't been able to figure it out. What I want to achieve is change the message depending on some form values the selected on the last question. I've created a custom module and extended the WebformHandlerBase and created a confirmForm function but I am not seeing anything once the form is submitted.

Again, it is submitting through ajax so I am not sure if that has anything to do with it.

Here is what I have tried so far


namespace Drupal\cbed_ux\Plugin\WebformHandler;

use Drupal\Core\Form\FormStateInterface;
use Drupal\webform\WebformHandlerBase;
use Drupal\webform\WebformSubmissionInterface;
use Drupal\webform\WebformInterface;
 * Form confirm handler.
 * @WebformHandler(
 * id = "quiz_handler",
 * label = @Translation("Quiz Handler"),
 * category = @Translation("Quiz Handler"),
 * description = @Translation("Quiz Webform handler."),
 * cardinality = \Drupal\webform\WebformHandlerInterface::CARDINALITY_UNLIMITED,
 * results = \Drupal\webform\WebformHandlerInterface::RESULTS_PROCESSED,
 * )
class QuizWebformHandler extends WebformHandlerBase {
  public function confirmForm(array &$form, FormStateInterface $form_state, WebformSubmissionInterface $webform_submission) {
    drupal_set_message ('submitted!!');

The form submits, but I do not see my kint or set message

Tags : 8 webform

Answers 1

Did you attach your WebformHandler to your webform via /admin/structure/webform/manage/WEBFORM_ID/handlers?

Your QuizWebformHandler::submitForm method does not match the WebformHandlerInterface::submitForm definition and should be throwing a fatal exception.

December 12, 2017 18:51 PM

Related Questions

Webform Rules - Create a Drupal User

Updated November 24, 2017 14:07 PM

Hide webform after the user's first submission

Updated May 16, 2017 17:07 PM

How to get instant result after submitting webform?

Updated September 14, 2017 12:07 PM