Stateful Forms enhanced?

Hi there Yii community,

as you know one possibility to store page states is provided with Yii’s stateful forms. Nevertheless it needs to have a page rendered containing a CHtml::StatefulForm. I was wondering if it could be possible to simulate Requests containing POST data for actions without attached views, that are only used for processing and redirecting somewhere else. It is possible to generate redirects setting GET Variables in the URL. How about using a library like cURL to generate a redirected site request with POST variables?

Background of this idea is, that I am currently building a form wizard based on an modified version of the CWizardBehavior supplied in topic For reasons of code separation I’d like to some setup stuff in an register/onStart action that does not have any view attached. Instead this action finally redirects the user to the first ‘real’ wizard page and it would be very cool to have some POST variables prepared for this redirect call. But at least I think that it could be of advantage to generate redirects with POST variables setup not only for this purpose. What do you think? Possible?



I’m not sure I understand your problem but can you use sessions?

I mean… instead of making a POST request… why not put needed data in the session (you can use setState())

Hi Mdomba, thanks for your suggestion, it seems to work this way. But on the other hand I do need the initialization value to get accessed globally and for a longer period of time, but only in the context of the wizard initialization. So I have to take care to unset it from the session right after the initialization step.

A main argument I feel it is difficult to estimate its seriousness is, that according to this IBM Tech Article (for java-driven webapps) HTTP Sessions are not thread safe. My apprehension is, that in coincidence of huge server load and delayed handling of requests (e.g. open in new tab twice) this could lead to a state, where two wizards are initialized identically. This would generate to a mixin of user input if they are both treated in parallel (e.g. to copy and paste in similiar workflows), leading to inappropriate results. With a volatile POST initialization I would evade such kind of trouble.

Is this apprehension realistic? Is the article only meaningful for java webapps? Does PHP or Yii cares for thread safety somehow? Is it possible that a CWebUser instance is accessed from different PHP Threads?



I just stumbled over another problem. If I provide the initial info with a session variable which I want to unset afterwards, the user is not able to use its browser back button to get back to the first page, because the wizardId is lost. I know, the user should not do it this way, but there are a lot of senior people who will do it nevertheless.

I don’t know your situation… but if someone opens in new tab twice… thats always the same user… it’s not two different users…

For the browser back problem… I think is’t the same with the POST data…when hitting back button after some data is posted the browser asks to post again the POSTed data and you cannot go two pages back…

Again I don’t understand exactly your need, but if session is not OK, you can maybe use the database to store the needed data but then you have in some way to distinguish different users…