Back button in multiple page form : document expired

Hi there,

I’ve created a multiple page form as a wizard. Each step has its own action and its own view that contains a stateful CActiveForm.

On each step when the user presses “Next >>” I read the form data with $_POST, creates the active record instance, saves it and I redirect to the next action (next wizard’s step).

The problem I have is that when the user plays with the back and forward buttons of the browser I get the "Document expired" error message.

I would have thought that the stateful => true in CActiveForm would have avoided this, but it doesn’t.

Anyone has an idea/best practice to handle this ?

Thank you



I’m not answering directly to your concern although I can imagine what you describe.

In my case, I either:


[*]use jQuery to handle the form subdivision into states (in fact playing with logical fieldsets and toggling their visibility

[*]communicate between wizard steps through Ajax, so technically there’s no navigation buttons.


But in both cases, I have to handle the wizard navigation :)

A solution would be to use redirect() function after form is submitted.

Thanks guys for your answers.

I’ve done a lot of tests today, and I really don’t understand what’s going on with Yii (or PHP in general) and the back/forward button…

For example I’ve taken the hangman demo into my project. In its original form you can do as much back and forward without ever having a document expired browser error.

In my project the hangman demo does not work with my layout. My layout contains a login module and some logic to generate the menu according to the user role. I’ve commented out every PHP logic and then the hangman demo works. Then I realised that only having this is my layout: if (Yii::app()->user->isGuest == true) breaks the back/forward browser navigation (document expired).

Then in my wizard I’ve got some steps where back/forward work fine and some steps where I get the document expired error… I really can’t see what could be causing those issues…

I am really puzzled. Anyone has some insight with this ?



this should be easy to achieve just use statefulForm. More info:

Thanks for your reply but I am already using stateful form…

I really don’t understand why some of my pages of my wizard expires when I click back and some don’t… I really can’t see anything different!

Another option would be to use one of the tab widgets, and display each step of the form on a seperte tab. Then submit the whole thing in one POST.

Just a thought

I think it’s time to show some code

$this->widget('zii.widgets.jui.CJuiTabs', array(


        'Static tab'=>'Static content',

        'Render tab'=>$this->renderPartial('pages/_content1',null,true),

        'Ajax tab'=>array('ajax'=>array('ajaxContent','view'=>'_content2')),















            'title'=>'Static tab',

            'content'=>'Content for tab 1'



            'title'=>'Render tab',




            'title'=>'Url tab',








both are from Yii Playgound. They have alot of good examples, you might want to check them out.

Just change your Tab titles and split up your form elements on the various tabs.

You might also look at the Wizard-Behavior extension. The forum topic is here