Forums

How to clear form after submit

sidprice 28 Feb, 2015
I am trying a very simple form that I need to place data into a DB table. The first time I load the form it is blank and I can enter data. I submit the data and it is written to my DB table, however when the form reloads the same data shows. How can I show a blank form after the submit?
Very nice component! πŸ˜€
Sid.
GreyHead 28 Feb, 2015
Hi Sid,

This is probably your browser autocomplete trying to be helpful. You can set autocomplete off in the input Extra settings if you plan to enter a lot of data yourself.

Bob
sidprice 28 Feb, 2015
Thank you for the hint, however that is not the issue. I turned off autocomplete and the issue remains :o(
Sid.
GreyHead 28 Feb, 2015
Hi Sid,

Please post a link to the form so I can take a quick look.

Bob
sidprice 28 Feb, 2015
Here you go, still primitive but functional:

http://www.iatcb.org/index.php?option=com_chronoforms5&chronoform=ChronoFormTest

Sid.
GreyHead 28 Feb, 2015
Hi Sid,

There are no AutoComplete off settings but that doesn’t seem to be the problem. What do you have in the Form On Submit event? Please take a Form Backup using the icon in the Forms Manager and post it here (as a zipped file) or PM or email it to me and I'll take a closer look.

Bob
sidprice 28 Feb, 2015
Here it is,
Sid.
GreyHead 28 Feb, 2015
Hi Sid,

Hmm . . . ChronoForms doesn't do quite what I expected.

I found two ways to fix this, but first please remove the HTML (Render Form) action from the On Submit event.

a) You can use a ReDirect action from the Utilities Group at the end of the On Submit event and set the URL to
/index.php?option=com_chronoforms5&chronoform=ChronoFormTest


b) You can add a Custom Code action with this code in it followed by an Event Loop action pointing back to the On Load event (that's the default setting):
<?php
$form->data = array();
?>

Either method works - the ReDirect is simpler, the Custom Code allows more flexibility should you need it. e.g. you could unset only some of the data values and leave others.

Bob
sidprice 28 Feb, 2015
One beer is yours! I used the redirect and it works like a charm,πŸ˜€
Thanks,
Sid.
This topic is locked and no more replies can be posted.