I’m trying to write a plugin for the following scenario:
- Via Admin, I want the user to be able to curate a list of events
- Each event has different fields, like
title
,data
,location
and many more - Visitors should be able to “subscribe” to events, via a simple form
- Visitors need to be able to select the events they are interested in, then submit their name and e-mail address
- The visitor’s data, including the events and the event’s details, need to be sent via email as well as saved so they can be evaluated later
The forms
plugin seems generally to be a good fit; it has mail and save actions that will generally do what I’m looking for. Using the data-manager
plugin allows to inspect and download the saved data, which works fine.
No matter what approach I try, I run into one or multiple of these problems:
- Can’t add the selected event’s details to the submitted data
- Adding the event’s details to the submitted data does not work without JavaScript
- The solution can not easily be wired up and maintained via Admin for non-power-users
My “best” solution so far looks like this:
- Curate a list of events in the page headers (can be exposed via blueprint)
- Add a form to the page and make sure there is a hidden field with a known id/name
- In a custom template, create fake “subscribe” toggles for each event
- In the template, with JavaScript, add or remove all of the selected event’s details to the hidden form field as a JSON string
- In the template that processes the form for email and data, have custom logic to process the JSON string accordingly
This seems like a dirty hack at best. Any suggestions as how to do this properly?