Open Collective
Open Collective
Loading
Individual users can now customize a webform's results table
Published on April 20, 2020 by Jacob Rockowitz

Background

The Webform module for Drupal 8 provides a customizable table of submission results. The table of submission results does not use Drupal's Views module but does extend Drupal's EntityListBuilder, which "defines a generic implementation to build a listing of entities." The WebformEntityListBuilder allows users to filter, sort, and add/remove columns from the submission results table. The below screencast shows how the submission results table can be customized. 

The goal of this user experience is to provide a quick and easy way to review submissions without requiring or expecting someone to use a View. Of course, developers and advanced site builders can replace the Webform module's submission results table with a custom view. Here is a video showing how to customize and improve the Webform module's Views Integration.  

Every instance of a webform and webform node submission results table can be customized by anyone that can update the webform. Every submission reviewer will see that same customized table of submission results, which is fine for basic forms with a few reviewers. A problem arises for complex forms with very different reviewers. For example, in an application review process, evaluators might want to see certain table columns while an administrator might want to see completely different table columns.  

For complex webforms, every user should be able to decide what information is visible on a webform's submission results table. 

Approach

Luke Leber recognized this problem and created Issue #3108433: Allow users to personalize the submission list in the Webform module's issue queue. Luke suggested using Drupal's UserData service along with the existing State API implementation. Without getting into the weeds (of code), Drupal's State API "provides a place for developers to store information about the system's state," in this specific use-case, a webform's submission results. The UserData service provides a mechanism to store user-specific information for each user securely. The fact that Drupal provides two well-thought-out storage mechanisms with very similar APIs made it very easy to store and manage a user's personalized submission results table. The remainder of the work was setting up the needed configuration settings and user experience for allowing users to personalize the submission results table.

Allowing users to customize the submission results table

Since most webform owners probably don't immediately need this enhancement, allowing users to customize the submission results table, can either be enabled for all webforms or individual webforms on a case-by-case basis.

To allow users to customize the submission results table for all webform go to 'Webforms > Configuration > Submissions' (/admin/structure/webform/config/submissions)

To allow users to customize the submission results table for an individual webform go to 'Webforms > {Webform Name} > Settings > Submissions' (/admin/structure/webform/manage/{webform}/settings/submissions) 

Finally, allowing users to customize the submission results table can also be done using the 'Customize table' modal form. 

Customizing a webform's submission results table

Once users can customize a webform's submission results table, the 'Customize' button's label is changed to 'Customize my table' and is visible to any user who can view the webform's submission. Clicking the 'Customize my table' button will open a modal where users can add, remove, and sort columns. Any user who can update the webform will also see a 'Customize default table' button in the modal, which is used to define the default and initial submission results table displayed to all users.

Conclusion 

The 'Results' tab provides a quick and straightforward way to view webform submissions.

I listed the 'Results' table as one of my favorite Webform things, and it is great to make this feature even better. I appreciate Luke's nudge to improve the Webform module's use-case and user experience. I hope for people building complex webforms with lots of reviewers; this enhancement makes your job a little easier.

Backing the Webform module

Open Collective is providing us, Drupal, and Open Source, with a platform to experiment and improve Open Source sustainability. If you appreciate and value what you are getting from the Webform module, please consider becoming a backer of the Webform module's Open Collective.