inventory-hugo-theme
inventory-hugo-theme copied to clipboard
[mini project] Forms 2.0 with data template
Note: This is a mini project intended for Outreachy May 2022 round applicants. This task is more advanced and will take more time to complete during the contribution period.
Summary
Devise a new way to dynamically create forms with different questions, response types, and config options from a YAML data template.
Background
Is the new feature related to a problem? Describe the problem: A basic contact form exists for the site already (see contact
layout and rsvp
layout). These forms must be created manually and customized question by question.
What does the new feature look like to you?: A better way to handle forms would be to create them dynamically from programmable data, without creating a new layout for each form.
Details
This task involves more scripting and understanding how data objects move through Hugo.
The proposal is to explore using Hugo data templates as a way to create scriptable forms. You could take these steps to approach this issue:
- Create a data structure for forms. Each object can consist of a string for a question, and then another data structure for different response types (e.g.
yes or no
, radio buttons, checkboxes, etc.). - Explore third-party tools to use for building forms. Currently, we use Formspree.io but this may not be sufficient. There are other promising tools out there (see this Hugo discussion topic or KwesForms.
- Convert the last RSVP form (example here into a page using the data structure you created. Use the third-party tool chosen previously to build the form.
- Write documentation for how to create new forms through a Hugo data template.
You can also ask any questions to help clarify your understanding.
Outcome
- Simplify creation of forms through a data template, without requiring changes to layout code
- Gain a deeper understanding of data objects with Hugo