2

I'm creating a website where members have a form of questions to fill in each day. But within this form is a another set of questions that are always the same each day, but will have different answers in each day (it's like a diary entry, but built up of various fields).

Is there a way in Sprout Forms for a form to be almost "embedded" in others? So that if the fields in the embedded form are changed they then change across all the parent forms it is included in, if that makes sense?

The only way I can think to do it at present is create a form with 2 tabs: main and diary. The main tab will contain specific fields for that day, the diary tab will have the set questions that are asked each day. And then I do a "save as" to duplicate the diary fields into another form and change those in the main tab. Issue is that if the diary structure ever gets changed / updated I would have to manually do this perhaps 30 or so times.

1

There is no default way to add a form within a form in Sprout Forms. Your proposed manual solution seems like a decent approach, but whenever you change a question on an existing form you will also be altering the historic data in any of your reports.

A two-forms approach

A more straightforward approach may be to make your process two forms. Have a primary form that has the core questions that don't change and a second form that the users are directed to for the questions that do. You could use a Form Relations as a Global Field or on a particular Single to assign which secondary form was needed and should be able to link between the submitted entries by tracking the IDs via a Sprout Fields Hidden Field or developing a custom front-end field that created the relationship in a more user-friendly way.

Using two forms will help you maintain accurate historic data and stick within existing functionality which will likely be easier to maintain in the long run.

A custom field approach

More speculatively, you could potentially develop a custom plugin and custom field that help you do this. It would definitely require a bit of planning, and I probably would vote against going this route, but to highlight some of the challenges you would face, here are some initial thoughts on what that might look like:

  • The fields that change would probably need to store data in a similar way. If all the fields that needed to change were Plain Text fields, that will likely be much easier of a problem to try to solve than if you need to swap questions that relate to different types of fields. It will likely be easier if the number of questions also stayed the same.
  • Sprout Forms stores fields locally to each form created, so you would not be able to use the Field Settings to control global attributes, you would need a separate custom field plugin settings area where you could control settings, such as the labels of the questions that change, across all instances of where the fields are used.
  • You'd probably also run into some challenges on how to create reports on the historic data. If answers to the questions of the first month relate to different questions than the answers to the data of the second month, you'd also have to find a way to store the questions that were being answered as part of the form submissions to know what the responses were actually referring to.
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.