One of our most interesting clients is a nonprofit working to increase legal access. This work centers around simplifying the process of filling out a long and complex series of legal forms. How complex? So complex that they are best handled by multiple webforms, which saves the clients and attorneys time because repeated information – a major headache for anyone who’s filled out a government or legal form – is only entered once.
Using multiple Webforms improves the performance of the Webform build UI for admins and editors, breaks up the work into bite-sized pieces for users completing a very long legal form, and allows reusable data from a Webform submission to pre-populate multiple legal forms.
The Method
We start with a custom entity called a Webform Packet, with a multiple value Webform reference field and a few other things that we’ll cover in future posts. The reference field uses an autocomplete widget, which we limit to a category of webform called datasets, which is what our client calls the webforms they use in our packets.
Now that we’ve got a group of Webforms, we present them to the user on a node that references a packet. We display the completion status of each dataset, and we calculate the state of completion for the entire packet. Merge 1 and Merge 2 are the datasets in the packet in the image.
A user-facing use case
When users are filling out multiple forms, they shouldn’t have to re-enter basic information. For example, you might be getting help with a divorce, changing your name, and making a child support request. Each of these legal forms would need your name, address and other basic information. You fill out the “Basic Info” dataset on the divorce form and complete that packet. When you start the name-change form, which also uses that dataset, the basic info dataset already has your answers from the divorce form. Even though the data is there, however, we mark the dataset as “needs review,” and the client would have to check and submit it before calling it completed.
When all datasets are completed the user is allowed to download or email an official legal form as a PDF containing all of their answers, with calculations and data manipulations where needed. The merging work will be covered in a future post.
The Custom Glue
We do a lot of custom checking in our theme preprocess functions to come up with dataset and packet statuses.
Webform configuration
As previously mentioned the Webforms are categorized as datasets. We require the source entity to be populated with query string parameters, which lets us keep track of the node (or group) so we can associate the webform submission with the correct packet. We autofill the form with previous submission values, and we have a patch that allows Webform to ignore the source entity when doing this (normally it would only work on the same source) so we can reuse the data in multiple packets.