Forums

event switcher for 2 submit buttons

teldrive 25 Mar, 2014
Answer
: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';
 }
 ?>
BNDragon 09 Sep, 2014

: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';
 }
 ?>



You saved my day๐Ÿ˜€

Reaaaallllyyyy Thanks man๐Ÿ˜‰
GreyHead 11 Sep, 2014
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
BNDragon 12 Sep, 2014
Hi Bob,

To me 'enviar' and 'guardar' is just fine, since I'm portuguese. ๐Ÿ˜€

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

Thanks Bob๐Ÿ˜‰
This topic is locked and no more replies can be posted.