NodeBB-Community / nodebb-plugin-forms

Forms for NodeBB
2 stars 4 forks source link

Multistage forms #8

Open pitaj opened 9 years ago

pitaj commented 9 years ago

Multistage forms are done with the newForm action:

actions: {
  submitResponse: [
    { newForm: "accept-member" },
    { notify: [ 4, 10, 15 ] },
    { createTopic: "category" }
  ],
  editResponse: [
    { editForm: "accept-member" },
    { notify: [ 4, 10, 15 ] }
  ]
}
actions = {
  newForm: function (newFormId, submission){  /* create new form */ }
}
yariplus commented 9 years ago

Would the newForm be attached to the containing form in the designer or a completely separate form?

What about viewing the form, would they be on the same page, linked together, tabbed, etc?

pitaj commented 9 years ago

Good questions

In the designer, it would show as "add a new stage." That button would open a new form creation thing (requires the ability to have multiple form states). When the sub-form was finished and saved, we would then set the newForm action to the ID of the sub-form (which is in itself a complete and separate form).

Viewing the newForm would be just like viewing any other form. The difference is that it has the submission from the parent form as part of it. So it's like viewing the submission and filling out a form at the same time.

yariplus commented 9 years ago

Okay good. That's more-or-less what I was thinking as well.

On the designer side, this shouldn't be too hard. The big thing I have to do is add a dropdown/tablist to change the currently being edited form, would be hard to tell what's going on with a bunch of forms and subforms all on the same page as they are now.

Storing submissions for each form might be more complex, I don't think we want to have separate submissions objects stored for each stage/subform, but combine them into one submission that knows part of the results are a stage. Needs a separate issue for Submission Schema.

Submitting a new stage should be no problem, it's basically the same as editing. Could append some extra data to the form tag like 'parentForm'

pitaj commented 9 years ago

I think storing them separately would be easier to implement, but its up for debate.