Buy Now
Sign in

event switcher for 2 submit buttons

teldrive , March 25 2014
Answered
Featured
teldrive

:D Just to feedback with simple code how differentiate events for two submit buttons
in submit action you must insert event switcher and insert php code that uses different names off buttons

				<?php

if ($_POST['enviar'])
{
return 'success';
}
elseif($_POST['guardar'])
{
return 'fail';
}
?>

Teldrive

BNDragon

[quote="teldrive"] :D Just to feedback with simple code how differentiate events for two submit buttons
in submit action you must insert event switcher and insert php code that uses different names off buttons

				<?php

if ($_POST['enviar'])
{
return 'success';
}
elseif($_POST['guardar'])
{
return 'fail';
}
?>
[/quote]

You saved my day :D

Reaaaallllyyyy Thanks man ;)

Sorry for my english, any problem understanding me, let me know, I will try to explain myself better! ;)

GreyHead

Hi,

teldrive's code is fine - and here's a slightly updated ChronoForms version.

I would change the Events in the Event Switcher to be 'enviar' and 'guardar' (or 'send' and 'save' if you prefer) because these will be easier to understand when you come to re-edit the form later:

				<?php
if ( isset($form->data['guardar']) && $form->data['guardar'] ) {
return 'guardar';
} else if ( isset($form->data['enviar']) && $form->data['enviar'] ) {
return 'enviar';
}
?>
You might also need to handle the case when neither is set!

Bob

ChronoForms technical support
If you'd like to buy me a coffee or two, thank you very much

BNDragon

Hi Bob,

To me 'enviar' and 'guardar' is just fine, since I'm portuguese. :D

Your make a good point about the case when no option is set, I need to add that case.

Thanks Bob ;)

Sorry for my english, any problem understanding me, let me know, I will try to explain myself better! ;)