• Development

    Overriding a Webform Confirmation Message in Drupal 8

    There are a few reasons you may need to override a webform confirmation:

    • Out of the box webform doesn’t allow you to add some tags (e.g., <button>) to a webform confirmation message. When you save it strips them out.
    • What if you needed to alter the webform message based on the values submitted in the webform?
    • What if you needed to alter the webform message based on where the user saw the webform?
    • etc…

    Thankfully, you can use a standard preprocess hook to override the confirmation output.

    In this particular example I needed to override the output of the message to include a button tag. I needed this to only happen if specific GET params had specific values.

    First, I modified the confirmation message settings as shown here: