updating webform submission display by using form

So, this is what I’m trying to do. I’ve got a webform submission filled in and saved to the database. When viewing the submission (node/nid/submission/sid). I want to show a form, which ask the user for a key. When the key is filled in I want to change the display of the submission (not the data in the database) using the webform_submission_load() hook. This is the code right now:

// webform hook function mymodule_webform_submission_load($submissions) {    $key_status = mymodule_get_key_status();    if($key_status) {       //change the submission display values    } }  // return TRUE or FALSE, depending on form submit function mymodule_get_key_status($setkey = FALSE) {    $status = &drupal_static(__FUNCTION__);    if(!isset($status)) {       $status = $setkey;       // display form when key is not provided       if(!$status) {          $getform = drupal_get_form('mymodule_form');          $output = drupal_render($getform);          drupal_set_message($output, 'form', FALSE);       }       // key provided in form, so don't display the form       else {          $errors = drupal_get_messages('form');       }       }    return $status; }  // form submit callback     function mymodule_form_custom_submit($form, &$form_state) {        if (isset($form_state['values']['form_value'])) {           $key = $form_state['values']['form_value']);           drupal_static_reset('mymodule_get_key_status');           mymodule_get_key_status(TRUE);        }     } 

When viewing a submission I see the submission and the form. When I submit the form nothing changes and the form is displayed again. When I debug the return value of the mymodule_get_key_status function the following happens. First the function return FALSE, then the form calls the function and the function returns true. After that the function is called again by the webform hook. The function returns false again… Not what I expected. When I call mymodule_get_key_status(); in the form submit callback it returns true. So the drupal_static is set properly.

Why isn’t the code working as I expected?

This article was republished from its original source.
Call Us: 1(800)730-2416

Pixeldust is a 20-year-old web development agency specializing in Drupal and WordPress and working with clients all over the country. With our best in class capabilities, we work with small businesses and fortune 500 companies alike. Give us a call at 1(800)730-2416 and let’s talk about your project.

FREE Drupal SEO Audit

Test your site below to see which issues need to be fixed. We will fix them and optimize your Drupal site 100% for Google and Bing. (Allow 30-60 seconds to gather data.)

Powered by

updating webform submission display by using form

On-Site Drupal SEO Master Setup

We make sure your site is 100% optimized (and stays that way) for the best SEO results.

With Pixeldust On-site (or On-page) SEO we make changes to your site’s structure and performance to make it easier for search engines to see and understand your site’s content. Search engines use algorithms to rank sites by degrees of relevance. Our on-site optimization ensures your site is configured to provide information in a way that meets Google and Bing standards for optimal indexing.

This service includes:

  • Pathauto install and configuration for SEO-friendly URLs.
  • Meta Tags install and configuration with dynamic tokens for meta titles and descriptions for all content types.
  • Install and fix all issues on the SEO checklist module.
  • Install and configure XML sitemap module and submit sitemaps.
  • Install and configure Google Analytics Module.
  • Install and configure Yoast.
  • Install and configure the Advanced Aggregation module to improve performance by minifying and merging CSS and JS.
  • Install and configure Schema.org Metatag.
  • Configure robots.txt.
  • Google Search Console setup snd configuration.
  • Find & Fix H1 tags.
  • Find and fix duplicate/missing meta descriptions.
  • Find and fix duplicate title tags.
  • Improve title, meta tags, and site descriptions.
  • Optimize images for better search engine optimization. Automate where possible.
  • Find and fix the missing alt and title tag for all images. Automate where possible.
  • The project takes 1 week to complete.