Warning: Undefined array key "wp:featuredmedia" in /home/rajkar/public_html/blogsdir/blog-details.php on line 38

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 38

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 38

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 38

Warning: Undefined array key "wp:featuredmedia" in /home/rajkar/public_html/blogsdir/blog-details.php on line 39

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 39

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 39

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 39

Warning: Undefined array key "wp:featuredmedia" in /home/rajkar/public_html/blogsdir/blog-details.php on line 40

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 40

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 40

Warning: Trying to access array offset on value of type null in /home/rajkar/public_html/blogsdir/blog-details.php on line 40
Drupal 8 how to get value of the webform submission in webform confirmation twig file - Rajkar Global CMS - Rajkar Global Consultancy Private Limited
Blog Image

Drupal 8 how to get value of the webform submission in webform confirmation twig file

Put the below code in youractivetheme.theme file

/**
* Implements hook_preprocess_HOOK().
*/

function [theme]_preprocess_webform_confirmation(&$vars) {
if ($vars['webform']->id() == 'put your webform id') {
// Set your custom message here
$markup = t('Thank you for your feedback.');
$vars['message']['#markup'] = $markup;
}
}

/// How to customise the message based on the submitted value

/**
* Implements hook_preprocess_HOOK().
*/

function [theme]_preprocess_webform_confirmation(&$vars)
{
if ($vars['webform']->id() == 'put your webform id')
{
// Get the submitted form value using the below command
$submittedFormValues = $vars['webform_submission']->getRawData();
if($submittedFormValues['field_name'] == 'some condition or value'){
$markup = t('display message 1');
}
else
{
$markup = t('display message 2');
}
// Set your custom message here
$vars['message']['#markup'] = $markup;
}
}



Author: admin

Vinod Ram has been in Software Industry since 2006 and has experience of over 16 years in Software Development & Project Management domain specialised majorly in LAMP stack & Open Source Technology, building enterprise level Web based Application, Large Database driven and huge traffic Websites and Project Management. He loves to write information articles and blog to share his knowledge and experience with the outside world and help people to find solution for their problems.