Here is how i implemented a two-step form for a client request for a site 
that I am working on right now without using javascript. Basically in step 
one the client fills out their contact information and then in step two they 
select what market they are in and give the address of their business. The 
main idea is to use validation groups and hidden fields.

The entity for the form is the ClientRequest. You can see the validation 
groups in action. Here is the code along with the 
annotations: http://pastie.org/1923563

Next I setup the form type for the client request. I have a base 
ClientRequestType that I extend and then override the buildForm() method. 
The default options for the form are returned in the base class in case you 
were wondering. Here is the code: http://pastie.org/1923571

Now the controller. Basically what I do is i create the form for step one in 
the action then if the request is type POST and the form is valid I create 
the form for step two and render it. I set the validation groups for each of 
these accordingly. Here is the full controller: http://pastie.org/1923689

That is basically it. Using this process all of the data is validated, no 
javascript is requried and nothing is saved until the final step is 
completed. There is no previous page integration done in this example, but 
it wouldn't be that hard to implement. In my actual project a lot of the 
form creation is abstracted out using the DIC, so forgive me if there is a 
typo or a syntax error in the pasted code of the controller. I did not have 
time to test it.

If anyone knows of a better way to do this without javascript, please post!

Dustin

-- 
If you want to report a vulnerability issue on symfony, please send it to 
security at symfony-project.com

You received this message because you are subscribed to the Google
Groups "symfony users" group.
To post to this group, send email to symfony-users@googlegroups.com
To unsubscribe from this group, send email to
symfony-users+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/symfony-users?hl=en

Reply via email to