I want something like this: in my form I want 2 submit buttons ("Button 1" and "Button 2"). If you click on "Button 1", an event "Show Thanks Message" has to display. If you click on "Button 2" another event "Show Thanks Message" has to display. Can't be that difficult I think? But I can't achieve my goal :-(
This is what I have done: I made a form with 2 'Submit' buttons:
1st button
========
Name: submit1
ID: submit1
Text: Button 1
2nd button
=========
Name: submit2
ID: submit2
Text: Button 2
"On Submit" I put an "Event Switcher [GH]" action with this php code:
<?php
if ($_POST['submit1'])
{
return 'event_a';
}
elseif($_POST['submit2'])
{
return 'event_b';
}
?>
I made an event "On a" with a "Show Thanks Message" action and a "Stopper" action.
I did the same with "On b" (with another "Show Thanks Message").
But I only receive a blank page when I click on "Button 1" or "Button 2".
What am I doing wrong? Probably something extremely stupid but I can't find what exactly?
This is what I have done: I made a form with 2 'Submit' buttons:
1st button
========
Name: submit1
ID: submit1
Text: Button 1
2nd button
=========
Name: submit2
ID: submit2
Text: Button 2
"On Submit" I put an "Event Switcher [GH]" action with this php code:
<?php
if ($_POST['submit1'])
{
return 'event_a';
}
elseif($_POST['submit2'])
{
return 'event_b';
}
?>
I made an event "On a" with a "Show Thanks Message" action and a "Stopper" action.
I did the same with "On b" (with another "Show Thanks Message").
But I only receive a blank page when I click on "Button 1" or "Button 2".
What am I doing wrong? Probably something extremely stupid but I can't find what exactly?
Hi geertmartens,
The PHP looks OK to me (though I would have used the $form->data[''] values instead of $_POST).
Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.
Bob
The PHP looks OK to me (though I would have used the $form->data[''] values instead of $_POST).
Please drag a Debugger action into the On Submit event, then submit the form and post the debug results here.
Bob
Hi Bob
Thanks for the answer.
I dragged a Debugger action into the On Submit event (first action). This is the result:
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => test-twee-knoppen
[event] => submit
[Itemid] =>
[submit] => Button 1
[0c0cb7efb74706647cf8885ec8472856] => 1
)
Validation Errors:
Array
(
)
Thanks for the answer.
I dragged a Debugger action into the On Submit event (first action). This is the result:
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => test-twee-knoppen
[event] => submit
[Itemid] =>
[submit] => Button 1
[0c0cb7efb74706647cf8885ec8472856] => 1
)
Validation Errors:
Array
(
)
Hi geertmartens,
There is no submit1 or submit2 in the submitted data - so the Event Switcher code is behaving correctly and doing nothing.
Bob
There is no submit1 or submit2 in the submitted data - so the Event Switcher code is behaving correctly and doing nothing.
Bob
Hi Bob
Maybe a stupid question. You write "There is no submit1 or submit2 in the submitted data", but how can you arrange that there is?
Regards
Geert
Maybe a stupid question. You write "There is no submit1 or submit2 in the submitted data", but how can you arrange that there is?
Regards
Geert
Hi geertmartens,
Set the names of the submit buttons to submit1 and submit2.
Bob
Set the names of the submit buttons to submit1 and submit2.
Bob
Hi Bob
I already did that (see my first post):
1st button
========
Name: submit1
ID: submit1
Text: Button 1
2nd button
=========
Name: submit2
ID: submit2
Text: Button 2
I already did that (see my first post):
1st button
========
Name: submit1
ID: submit1
Text: Button 1
2nd button
=========
Name: submit2
ID: submit2
Text: Button 2
Hi geertmartens,
Not according to the Debug output. Here's what I see with a submit button named submit1:
Bob
Not according to the Debug output. Here's what I see with a submit button named submit1:
Array
(
[option] => com_chronoforms
[chronoform] => test_submit
[event] => submit
[submit1] => Submit
[60bcd5cfa2fdcaf416dfb487571198c0] => 1
)
Bob
Hi Bob
The Debug output I posted was indeed the output where I renamed my buttons. I changed them back to 'submit1' and 'submit2' as mentioned in my first post. But this has still no effect. I receive blank pages when clicking on 'submit1' and 'submit2'.
This is the output I see:
When clicking on 'submit1':
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => test-twee-knoppen
[event] => submit
[Itemid] =>
[submit1] => Submit
[3b4a0024d84bc13b57e1724f64d18084] => 1
)
Validation Errors:
Array
(
)
When clicking on 'submit2':
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => test-twee-knoppen
[event] => submit
[Itemid] =>
[submit2] => Submit
[3b4a0024d84bc13b57e1724f64d18084] => 1
)
Validation Errors:
Array
(
)
The Debug output I posted was indeed the output where I renamed my buttons. I changed them back to 'submit1' and 'submit2' as mentioned in my first post. But this has still no effect. I receive blank pages when clicking on 'submit1' and 'submit2'.
This is the output I see:
When clicking on 'submit1':
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => test-twee-knoppen
[event] => submit
[Itemid] =>
[submit1] => Submit
[3b4a0024d84bc13b57e1724f64d18084] => 1
)
Validation Errors:
Array
(
)
When clicking on 'submit2':
Data Array:
Array
(
[option] => com_chronoforms
[tmpl] => component
[chronoform] => test-twee-knoppen
[event] => submit
[Itemid] =>
[submit2] => Submit
[3b4a0024d84bc13b57e1724f64d18084] => 1
)
Validation Errors:
Array
(
)
Hi geertmartens,
Then you get to debug your PHP . . .
I would use a test like this instead of if ($_POST['submit1']):
Bob
Then you get to debug your PHP . . .
I would use a test like this instead of if ($_POST['submit1']):
<?php
if ( isset($form->data['submit1']) && $form->data['submit1'] == 'Submit' ) {
return 'event_a';
} elseif ( isset($form->data['submit2']) && $form->data['submit2'] == 'Submit' ) {
return 'event_b';
}
?>
Bob
This topic is locked and no more replies can be posted.