1

I am wondering how one would setup a multi-step form in CFWheels.

Clearly I would need to store form data in the session etc as I go, but I would like to know the best approach from a wheels perspective to do this the 'wheels way'.

Do I have just one action in my controller that handles this? Or would it be best to seperate each part of the form out into separate actions?

Advise on this and possible code examples would be much appreciated.

Thanks, Michael

Michael Giovanni Pumo
  • 14,338
  • 18
  • 91
  • 140
  • You're basically asking for a discussion, which isn't a good fit for SO's format. Try the [cfwheels mailing list](https://groups.google.com/forum/?fromgroups#!forum/cfwheels). – Peter Boughton Aug 27 '12 at 22:42
  • I hear you - but I do in fact wish to discuss code too. I will be updating this question with code soon and I find SO better for this than Google groups. – Michael Giovanni Pumo Aug 27 '12 at 22:46
  • 3
    Having code doesn't automatically make it fit for [SO's Q&A format](http://stackoverflow.com/faq). Specific answerable questions = good. Vague "help me do a multi-step form" = bad. You really will get a far better response by asking on the cfWheels mailing list. – Peter Boughton Aug 27 '12 at 23:42

1 Answers1

1

The way I've done it in past is use Ajax calls and a jquery modal.

though the jquery modal is not important, I just like the aesthetic. a simple div replacement will also work.

If you cannot be sure that the users can use AJAX then it won't work for you, but you might be able to use a popup window.

The advantage of using Ajax calls for multi-step forms is that you can adjust the form content from one step to another. Another advantage is that you don't have to store user data in the cache or session. Because each time you send a form, you can use the POST or GET.

For this to work, the quickest way of setting this up is to use the plugin called RemoteFormHelpers. Then each step of the form would be a different controller (or the same one with a switch statement based on the data passed)

I think this is a pretty versatile way of doing this, but you cannot do a form that uses file-uploads, well not easily as ajax won't let you do it without some serious pain.

Daniel
  • 34,125
  • 17
  • 102
  • 150
  • I have thought about doing it the AJAX way, but I need to do DB checks on some of the fields as we go - so it could be tricky. For example, there are a possible 3 steps max, but providing something does not validate on the first step from a DB lookup, I then need to redirect the user and no more steps will be taken. I think my case is quite unique, hence the pain of making it work in CFWheels. – Michael Giovanni Pumo Aug 30 '12 at 09:38
  • It seems to me like ajax would be the way to go especially if you need to check information against the database. With ajax calls you can run through a controller on every submit and do the checks easily. – Daniel Aug 30 '12 at 16:02