Clear the form data after submit

camerata 15 Jul, 2013
After to submit the data of a miltipage form, when I back to the form (first page) all fields are displayed with the submited data when I wish to start with a new blank form. Do I need to include anything as custom code at the On Submit event?

Thanks in advance.
GreyHead 15 Jul, 2013
Hi camerata,

In the last 'Session to Data' action set the data to clear (I forget the exact name of the option).

Bob
camerata 15 Jul, 2013
Thanks, Bob. But I have not a session to data element (there are only custom code, email and thanks message on submut). Do I need to insert session to data?
GreyHead 16 Jul, 2013
Hi camerata,

You said it was a multi-page form so how are you passing the data between the pages?

Bob
camerata 16 Jul, 2013
Bob: Just I translated an old v.3 form. To pass the data I use hidden and displayed fields and the $form->data to recover. Probable it's not the more efective procedure bur it works fine. May be you could suggest something different specially to get clean the form after to submit it.

Thanks in advance.
GreyHead 16 Jul, 2013
Hi camerata,

You can try using a Custom Code action to unset $form->data at the end of the On Submit event; but I suspect that the problem may be that the browser is re-loading the values and not ChronoForms.

Bob
camerata 16 Jul, 2013
Just I have a custom code On Submit before to send an email notification and thanks page. Could I insert other custom code after thanks to unset $form->data? Coudl you make an example?

I suspect that the problem may be that the browser is re-loading the values and not ChronoForms.


My form get data from a table and update at last page. If I don't finish and submit the form and restart the process going to the first page, the form display the sent values to other pages and not the values from the table. If you submit the form, all data is updated correctly. When you start at first page (with other values), on the next pages the values displayed are not the database but the passed early.

I will be testing your suggestion to unset the form data... Thanks.
GreyHead 16 Jul, 2013
Hi camerata,

Yes, use another Custom Code action; set it to View mode and add
<?php
unset($form->data);
?>


It would probably be better to revise the form to use the Session to Data + Date to Session actions instead of using many hidden inputs if this is practical.

Bob
camerata 16 Jul, 2013
Thanks, Bon. It's very strange...

I have some like this at beginning of the first page form:

<?php
$user =& JFactory::getUser();
?>
<input maxlength="150" size="25" id="text" name="correo" type="text" value="<?php echo $user->email; ?>" <?php if ($user->email) { ?>readonly="" <?php } ?>/>


When I enter as no user, I can write an email at field, submit and it works. But when I enter as user, the email field doesn't display my email but the last email passed by the form (and I can't to change it since the readonly is active).

If I unser the $form->data or set $form->data['correo'] = ''; at beginning, the first page is ok (the user email is displayed correctly) but at second page I get an error since undefined var 'correo'.

The form works fine and I only need to solve this problem to avoid issues when someone wants to enter at form with two different emails or users.

Please, help.
camerata 16 Jul, 2013
As additional information, the issue could be related to the Joomla/browser cache or session life. When I return the form page after some time, the form starts correctly without data.
GreyHead 17 Jul, 2013
Hi camerata,

Are you sure that you aren't using the MultiPage action or the Session to Data / Data to Session actions?

Bob
camerata 17 Jul, 2013
Bob: Yes, I do use MiltiPage action but not Session to Date/Date to Session.
GreyHead 17 Jul, 2013
Hi camerata,

Ah OK, that's just a wrapper for the Data to Session / Session to Data actions. Please add a Session to Data action at the end of the last On Submit and set 'Clear After' to 'Yes' in the configuration.

Bob
camerata 17 Jul, 2013
Ok, Bob I did.

Probably when you finish and submit the form could be restart from zero. But if you restart after some pages (without submit last page) and enter other differen data, the pages doesn't display the correct data (recovered from database); some fields are correct and some other are values from past start...

My form gets an email address at first page and data from database to be displayed and edited for further pages.

Do I need to insert more Session to data at end of every page actions?

Thanks newly in advance.
GreyHead 17 Jul, 2013
Hi camerata,

You may not be able to handle that case where the user re-starts after some pages :-(

If you are using the Multi-Page action on every page that should be the same as using the Data to Session and Session to Data actions.

I'm afraid that here you have to look carefully at what is happening where and work through the logic of what is being displayed and why.

Bob
camerata 17 Jul, 2013
Could be a sollution to include in the pages a link to the first page?
Is it the same to link the first page that link to the form from the menu?
GreyHead 22 Jul, 2013
Hi camerata,

I expect that would work, but you still need to check the logic carefully.

Bob
camerata 22 Jul, 2013
Bob: The form works clearly when you enter with no recent access. If you restart before to submit or decide to come back shortly, it's crazy but entered data appears at fields with priority to recovered information from database...

I need a multipage form with the option to return or back to an early page for change options par example. I think that back and go to the first page buttons/links would not be a simple link (like the normal form link) but a process keeping the entered data (back) or completely restart (first). I don't know how to make this.

But it's ok. The system in general works fine. I will continue investigating.

Thanks.
GreyHead 27 Jul, 2013
Hi camerata,

It still sounds as though the data is being stored in the user session and not cleared at the end of the submission process :-(

Bob
camerata 27 Jul, 2013
Exactly, Bob. When the session expires, the form continues how you need...
GreyHead 27 Jul, 2013
Hi camerata,

Yes but then using Clear After in a Session to Data action at the end of the last On Submit action (with the right Session Key) should clear the data OK.

Bob
camerata 27 Jul, 2013
I don't appreciate differences with or without the Clear After in a Session to Data action at the end of the last On Submit.

Could it be possible to insert Clear After in a Session to Data action at beginning of first page to clean all data before to start?
GreyHead 27 Jul, 2013
Hi camerata,

It might work - try it and see . . .

Bob
camerata 27 Jul, 2013
Just did it. I don't see differences like at On Submit.
GreyHead 30 Jul, 2013
Hi camerata,

If this is still a problem the next step is probably to debug with some Custom Code actions to dump out the data in the User Session and work out why it isn't being cleared.

Bob
camerata 30 Jul, 2013
Bob: I'm not sure if this issue comes from session or browser cache.

My form has a first page where the user enter an email address (the user email by default). In the second page, the form get data (name and other) from a table and inserts them in the form fileds as values to be edited.

So, when the user continues to page three (to other options) but he decides come back (first page), if he enters newly the same email address, second page doesn't display the data from table but the previously entered values (page two). If other email is entered (page one), the form displays the entered data (not the table) new values...

I hope you understand my issue description. Thanks in advance.
GreyHead 30 Jul, 2013
Hi camerata,

If it's from the browser cache then there isn't a lot you can do - you can try the autocomplete='off' attribute but there is no automatic way to add that in ChronoForms.

Bob
This topic is locked and no more replies can be posted.