multi-step registration - symfony1

I am currently using sfDoctrineGuardPlugin and sfDoctrineForkedApplyPlugin for my user management.
This works well for me and users can register/login etc
The problem comes with the registration part. The Profile relation that I have is getting particularly large in terms of fields users are required to fill out on registration.
I was thinking of possibly creating a multistep process, possibly 2 steps.
Step 1 is the main details, such as name, username, password etc
Step 2 is the address and my other fields
I don't want my users to scroll down to fill out 25 fields on a single form
I'm not entirely sure how I'd do this and I cannot find any information regarding carrying out this.
Has anyone ever done this before and If so, could someone point me in the right direction of how I'd do this?
Thanks

I'd create a form class for every step. When processing the submitted form, save the submitted part to the session if validation passes.
In the end you'll have an array of validated values for every step, just compose your model object out of them, and save the object.

Here is a generic way of handling multi-step forms in Symfony:
How to 'validate' a Symfony form in steps - instead of calling $form->isValid()

Related

asp.net mvc. 3-step anonymous sign-up form: How to properly Create/Edit the record between steps

First-time poster, long-time admirer! :-) Coming from ASP.NET WebForms world and building my first MVC web app. Over the past month or so, I've watched a lot of videos and read a lot about MVC, EF Code-First, patterns, strategies, etc. Exciting!
Building an ASP.NET MVC 5 web application, which is to be a fairly simple, 3-step sign-up form on an anonymous portion of the web site. An [anonymous] user fills out "step 1," clicks "next," and data gets recorded into a database between steps (which is desired even if the user quits before finishing step 3).
So my approach so far is to build a single "Signup" controller with 3 controller actions for the 3 steps (along with their own ViewModels containing only the needed fields for each step):
Site/Signup/Step1 (creates a new record in DB and fills out some fields)
Site/Signup/Step2 (edits the record created in Step1 and fills out some other fields)
Site/Signup/Step3 (edits the record created in Step1 and fills out some other fields)
My question is, how do I best persist a unique identifier for the newly-created record from Step1 over to steps 2 and 3, safely, securely, conveniently?
There is an auto-identity integer SignupID, but that is not safe-enough to pass via querystring (.../Step2?id=xxx), as anyone could just type a different number and overwrite data in the database.
Some thoughts I've had so far:
Option: Generate a longer random number or alphanumeric code and store in DB, and use it as a URL parameter. Maybe even GUID without hyphens or something like that.
Option: Persist the identifier (auto-increment ID or the longer alphanumeric code) someplace other than the querystring. Maybe Session? TempData?
Option: Some combination of the two above, but with added crypto hashing or something, to ensure that the ID only works for some small period of time (say, an hour, or something).
I don't want to make this overly complex for a very small application with small number of users/sign-ups. Just need to make it not stupidly "inviting" for poking around, considering the form needs to be filled out by anonymous users.
I'd appreciate some thoughts from the community. Thanks!

Creating a workflow in a single form in Struts2

I'm using struts2-jquery-plugin-3.7.0. I'm looking for a component that can create a workflow by exhibiting (creating) multiple steps in a single form on a page in which the current step is processed partially and display the next step if and only if the current step passes validations.
All the steps must be performed sequentially in a defined order.
For example, in a user registration form, personnel information of a user must be filled up first before filling up her contact information and so on.
If any validation is violated while filling up personnel information then, the next step (to fill up contact information) must not be executed. It should only be executed, if no validation is violated in personnel information.
Currently, I can only see <sj:tabbedpanel> which doesn't seem to fulfill these requirements.
Is there any component that can be used in Struts2 to fulfill these requirements?
Long story short : I'm looking for exactly the same component as provided by PrimeFaces <p:wizard> Anyway, I need to create a workflow in which a single page of activities can be exhibited in different and sequential steps. Is there a handy way that can make it possible?
So you want a plugin-in or component for multi-step form in struts2. Well there is no such implementations now, but you can create one of your own. There are many so examples in google.
This one implementation I found in struts2.
Even this is not a bad option. You need to program the underlying logic :)
CSS3-Jquery

ViewModel with restricted validation or 2 forms with shared field?

I have been struggling to find a solution to this issue for some time now. Basically I have a View that has a field at the top where the user enters a payment amount. I then have 2 forms for 2 different payment methods. The first method is payment via card where card details are entered. The second is payment via a registered account where an account number is entered. When the user submits either form I need to also submit the payment amount from the field at the top of the view.
Currently I have implemented this using just a single form using a ViewModel which has 3 properties (sub models), the PaymentAmount Model, the PaymentCardDetais Model and the AccountDetais Model. The problem with this is that on submission, all model fields in the viewModel get validated. Obviously the user is going to always enter an amount but will only enter either card details OR account details. I'm not sure if this is the best way to implement this - any thoughts on this would be much appreciated. If it is te best way then I need to find a way to avoid validation on all the viewmodels sub models - is this possible?
Thanks in advance for your help.
James
You're right that the user will always enter an amount for both cases, but if I were you I would just avoid the DRY principle so useful when coding but not that much in terms of user interface and go with two independent forms one for each payment type and have an amount field in each one of them.
This way you solve your validation and form submitting problems.
Another option, if you really don't want to have two amount fields on the page I would consider letting the user first choose the payment method and then showing him only the form with the fields for the selected payment method.

Keep some information between different "new" forms

I have a form where the user can choose options from a lot of select boxes. The form is used to register several items from an RSS feed. The user fills in the form, clicks create and is presented with the same form for the next item in the list.
Sometimes, the same options are valid for several items in the list, and I would like to be able to save some of the selections done so the user doesn't have to make the same selection for the next items.
What is the best way of doing this? I've identified four ways of doing it:
Sessions
Just keep the values in the session hash. This will of course work and is very simple, but I have some undefined feeling that it is a bad idea. It will also not work if the user is using the form from different tabs in the browser.
Cookies
Basically the same as keeping them in the session, I think.
Profile
Can't be done in this case I believe, since profiles are shared between several users.
Database
The most complex way I've come up with is to keep the information in the database and use a query parameter to keep track of which information should be used. This is probably overkill, but in some ways the best way to me. I don't like the idea of keeping this kind of state in session or cookies.
Am I missing some way? Or something?
If after filling first form, some data is saved to db (object is created) then you can use this data from db to fill up new form.
If after filling first form, nothing is saved to db, then you can create in memory some objects based on params from previous post and based on this (on just on params) you can prepare new form. But of course data from previous form should be added as hidden fields in second form.

how to create wizard forms in ruby on rails

I'm trying to understand the best options for pulling off a wizard form in ruby on rails. Ideally I'd like to have it so the application signup has a back and next button that allows the user to submit data in steps.
So in step 1 they could fill out contact info. Once they are done they could click next and be on step 2 to fill out payment info, etc. If they make a mistake, they can click back and correct it. Some steps will be required, while others will not, but you do have to make it to the last step to submit the data to the database to sign up. They then need the ability to go back and fill out the past steps in the same fashion after completion. (example: perhaps if they clicked on a profile link they could recomplete the steps in the same fashion because they didn't want to complete all the steps right away. Maybe by being given a skip button before they completed the steps to sign up?). I also need validation to happen on what steps have been completed preventing them from moving onto the next step until corrected or completed.
Option 1) I've noticed that ajax has been recommended as an option in other questions on stackoverflow. The only problem I have with it is that the user would not be able to sign up if javascript was disabled. Ideally I'd like to have it be native to ruby on rails but I'm willing to work with whatever is necessary to get it to work.
You should watch this rails cast episode on multi step forms:
http://railscasts.com/episodes/217-multistep-forms
Be prepared to rewind and watch again. He's very quick!
There are a couple of plugins that provide wizzard construction facilitation in rails.
Acts as Wizard and Wizardly seem the most popular.
The main idea is to:
* create a model in the first step
* then edit it on subsequent steps,
* applying partial validation on each step and
* having the model implement some sort of state machine.
Wicked looks promising for rails 3:
https://github.com/schneems/wicked
Have a look at wicked, explained in this rails cast: http://railscasts.com/episodes/346-wizard-forms-with-wicked?autoplay=true
An alternative approach, for simpler multi step forms especially, is to simply show-hide parts of a single form depending on the step, this way you don't hit the database on every step but rather let the user build up his object until he's ready with a valid instance.
Such an approach strongly favors using a form class instead of working with the model directly (http://blog.codeclimate.com/blog/2012/10/17/7-ways-to-decompose-fat-activerecord-models/) and you need to tweak error message rendering a bit.
Pros: only one db hit, no hassle with persisting invalid instances (not null columns, before_save sanity checks for messed up attributes), no callback hell
Cons: more html sent to user, error message tweaks, requires a well built form class to be elegant and really useful

Resources