How to find what submit button is pressed

Mmax2 21 Oct, 2024

Good evening, I know that this particular question has already an answer, for example here: https://www.chronoengine.com/forums/topics/view/111163/how-to-skip-a-page#p403346

But I can't get it to work. I have 2 buttons:

and in the Submit of this page there is the PHP:

and then the NextPage action:

I hit the "Back" button, in the debug there is the following data:

but it goes forward. Where is my error? Thank you very much.

Max_admin 21 Oct, 2024
Answer

you should use this code, you need to check if the data exists or not:

if(isset($this->data["button_back"]))
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Mmax2 22 Oct, 2024

Thank you very much for your reply, the code works, but if I go back and then, when in that page again, I press "Next" button, I go backward.

This is because the data are maintained on changing page, this is the debug:

As you can see, both buttons are present (even if the button_back was not pressed now, only before), and the first one wins.

Max_admin 22 Oct, 2024

Yes, because data is stored in the session till the form is finished

You may use a Link as the back button, the link href should be the form URL + &chronopage=page-alias, this is explained here:

https://www.chronoengine.com/faqs/chronoforms/chronoforms8/how-to-create-a-multi-page-form-in-chronoforms8

to make the link look like a button, add the class = nui button

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Mmax2 25 Oct, 2024

Thank you again, now all works as desired.

The problem now is the style: with this class="nui button colored green left iconed" in the "a" tag (first button) I obtain this:

The desired style should look as this instead:

It's very difficult for me to obtain the correct look like that of a button. Will be possible (even in a future release) to have a button acting like an "a" tag?

Thank you very much.

Max_admin 25 Oct, 2024

Sorry, I forgot to tell you that the button view has "Button type" setting which can be set to "Previous page link", you can see it in action if you import the "Multipage form" from the demo forms included in the v8 installer:

How to find what submit button is pressed image 1

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Mmax2 25 Oct, 2024

Yes, thank you, but my problem is, if I use "previous page link" I can only go back to previous page and not for example go back two pages. That's why I asked you the possibility to set the page, otherwise I don't know how to solve my problem.

Max_admin 25 Oct, 2024

ok, so do it your way but check the code of that back button and make your link look the same, does this solve your problem ?

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Mmax2 27 Oct, 2024

You are right, thank you. I looked at the code and tried this solution:

but the PHP section is ignored. I don't know if I can use php this way, like you used it in your code.

Max_admin 27 Oct, 2024

how did you build your button earlier at this post:

https://www.chronoengine.com/forums/topics/view/111336/how-to-find-what-submit-button-is-pressed#p404069

?

just use the same code along with the class "left iconed", if you need to add an icon then use {icon:arrow-left}, do not use PHP for that

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Mmax2 27 Oct, 2024

Thank you very much, works well.

You confirm that there isn't a way to find which button is pressed, as data is stored in the session till the form is finished.

Thank you again.

Max_admin 27 Oct, 2024

you may check the $_POST array for buttons, this is the fresh post values and will not be affected by the form session

Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
You need to login to be able to post a reply.

VPS & Email Hosting 20% discount
hostinger