Hi, I’ve a question regarding CactiveRecord and the save event:
I’ve a large model with many attributes and i need to split it into 3 views.
Each view call a different action (ex. actionStep1, actionStep2, actionStep3)
It’s possible to istantiate the model into actionStep1, renderize the view, and when calling
actionStep2, retrieve the model instance created at actionStep1?
Sounds like you can store the values from page 1 & 2 into session and use it after submitting page 3.
Take a look at the extension wizard-behavior
Thanks Joblo, wizard-behavior sounds good
For a project where I had a very long form, I left the controller and the view unchanged, PHP-wise, and rather divided it in logical blocks that made my form steps in fact.
Using HTML, CSS, and JS (jQuery since it’s already loaded), I used <fieldset> tags for each block, and then hid them with JS when the view is loaded.
I added a simple breadcrumb in HTML and CSS, and used JS to hide/display <fieldset> blocks according to what is clicked in the breadcrumb.
It totally fit the goal.
One important thing: in my case, I didn’t need to validate each step, I did one validation for the whole form, since my main problem was just the form length.
Now, if you need to validate each step, or save the form gradually and recover it, like to allow drafts, etc. I also recommend wizard-behavior extension, although I haven’t had the opportunity to use it in a real project yet.