Forums

Multi Page, Debugger and lost values

emmexx 18 Jan, 2013
I'm creating a form that uses the Multi Page action to run a "wizard".
I open the form using a "token" with the cf_uid of a record because the wizard should update 2 fields of the record.

I setup the form as per FAQ and I thought it worked.
After changing a field name of an element the problem started.
I put a Debugger in every step of the wizard.
In the Debugger I see a value for both the old and the new field name. I mean The field name of the element was myfield and I changed it to newfield.
In the debugger I see:

Array
(
    [myfield] => abc
    [newfield] => def
...


The value of another element is wrong. The element is a simple Radio box with 2 values allowed, no Field Name and Field ID = "a_name".

I suppose I'm missing something of the inner working of Multi Page.

I just wanted the user to check some radio box and let the cf_id of a record to be updated "follow" the wizard. And on the submit action I wanted to set a field name based on the values selected by the user and update the record.
But now I can't trust the debugger or CF. 😟

On the onsubmit action I added a Custom Event Switcher that checks the value of a radio box in the 1st page of the wizard.

   $ret='fail';
   if(isset($form->data['a_name']) && $form->data['a_name']=='cancel')
   {
      $ret = 'cancel';
      $form->data['status'] = -2; 
   }
   else if (isset($form->data['a_name']) && $form->data['a_name']=='postpone')
   {
      $ret = 'postpone';
      $form->data['status'] = -1;
   }
   unset($form->data['a_name']);
   return($ret);


If I select 'postpone' in the 1st page of the wizard, the action associated to 'cancel' runs!
And the debugger confirms that the value that gets to the submit page is 'cancel'.

I'm a little bit confused.

Thank you
maxx
emmexx 19 Jan, 2013
Today everything works properly.
I suppose the problem was with the firefox cache. Anyway I'm worried because if cached values are sent to the server, I'll get worng results.

bye
maxx
GreyHead 19 Jan, 2013
Hi Maxx,

I doubt that the browser cache is the problem here, and probably not the Joomla! cache (though it should never be used with form pages).

I haven't tracked through in detail but I suspect that the problem is that form data is being saved in the Joomla! User session and not cleared at the end of the form processing. This is how the ChronoForms multi-page action works.

For most forms and 'real' users this isn't a problem because they are most unlikely to complete the form more than once in the same session.

When you are developing though it can be a pain in the neck. You can fix it by making sure that the User session data is cleared at the final point of submission. (And, if you like, also when the first page is first loaded.)

Using the Session to Data action with 'Clear After' set to 'Yes' will do the trick.

Bob
emmexx 19 Jan, 2013

I doubt that the browser cache is the problem here, and probably not the Joomla! cache (though it should never be used with form pages).



You're right, I was referring to "firefox cache" meaning something that has to do with session data, not files.

I haven't tracked through in detail but I suspect that the problem is that form data is being saved in the Joomla! User session and not cleared at the end of the form processing. This is how the ChronoForms multi-page action works.

For most forms and 'real' users this isn't a problem because they are most unlikely to complete the form more than once in the same session.

When you are developing though it can be a pain in the neck. You can fix it by making sure that the User session data is cleared at the final point of submission. (And, if you like, also when the first page is first loaded.)

Using the Session to Data action with 'Clear After' set to 'Yes' will do the trick.



Thank you, I'll do that.
I realized that I was mixing 2 different problems:
using the browser Back buttom while developing.
not assigning a Field Name to some of the values.

The 1st problem is a Session problem, as you suggested.
The 2nd problem is the way the Multi Page action works, I suppose: only elements with a Field Name are passed to the following page.

Thank you
maxx
GreyHead 19 Jan, 2013
Hi Maxx,

In the base case only elements with input names are carried forward, but if you use the Data to Session & Session to Data actions or the Multi-Page action then you can carry through the values from all the previous pages.

Bob
emmexx 19 Jan, 2013

In the base case only elements with input names are carried forward, but if you use the Data to Session & Session to Data actions or the Multi-Page action then you can carry through the values from all the previous pages.



I'm sorry Bob, but that is not the way it is working on one of my forms that uses Multi Page.
I put in the 1st page an element with the Field Name assigned and ane element with the Field Name blank.
In the 2nd page I put a debugger.
When I go from the 1st to the 2nd page, in the debugger there are the value and field name of the element with Field Name assigned. But there's no value or field name of the element with Field Name blank.

It could be my fault, I don't know, I followed your FAQ about Multi Page.
The "problem" could be that I'm loading the values of a record with DB Record Loader.

Anyway, I solved that problem by assigning the Field Name and unsetting $form->data['fname'] on submit.

Thank you
maxx
This topic is locked and no more replies can be posted.