Forums

Event switcher

vismay 28 Jan, 2017
Hi guys,

I'm trying to solve a big problem testing a simple form, in order to understand the behaviour of event switcher.

I've followed the FAQ of event switcher here:

https://www.chronoengine.com/faqs/70-cfv5/5255-how-can-i-switch-form-pages-in-cfv5.html

Its' working.

For example, I need to write something when I submit page_2 and something else when I'm in page_3.

page_1 is the first choice, so nothing should be written.

page_2 write something like "ok this is from page 2"

page_3 write something like "ok this is from page 3"

But actually happens something like this:

When I submit page_1 it writes the code of page_2 and when I submit from page_2 to page_3 it writes the code of page_3

So, basically BEFORE I fire the desire custom code.

Any idea?

Just for information the custom code is something like this:

<?php

$campo='2';

$db =& JFactory::getDBO();

$query = "INSERT INTO `prova` (
campo
) 
VALUES (('$campo')
);";

$db->setQuery($query);
    $db->query(); 
?>
vismay 28 Jan, 2017
My question:
hot to fire a custom code on "submitting" a page and not on "arriving" on a page....
Max_admin 28 Jan, 2017
Hi vismay,

Each event is a page, so you have 4 pages, load, submit, page2 and page3, you can display anything in any of them, your "event switcher" loads one of the page2 or page3 events inside the "submit" page because of the "event loop".

What's not working with your form exactly ?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
vismay 28 Jan, 2017
I have an event switch on page_1 that decide to go on page 2 or 3.

every page has a form, the fields should be written on database.

So, the page_1 form should be written, then I go to page_2, there is a form, when I submit I need to write the form on database and so on.

But what happen?

When I fill the form page_1 and I go to page_2 WRITE the page_1 and page_2.

When I go to page_3 write already the custom code on page_3 BEFORE I submit the form.

SO basically when I go to page_2 already execute the custom code ( where I write to database) on event page_2
Max_admin 28 Jan, 2017
Hi Vismay,

According to your setup, you process "custom code" at the same time you display the page, so what you said is expected.

You need to have the "save code" in the "submit" event of your pages, you have page1 submits to "submit", so you can save page1 in "submit", then you have both page2 and page3 submit to "submit", which is wrong, you better submit to another event and save there.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
This topic is locked and no more replies can be posted.