--which works fine and shows add or edit as required and for edit reads the appropriate record from the DBBut the event switcher never triggers the add event, only the edit eventdata["addedit"] == 'add') { return "add"; } else { return "edit"; }?>I have tried "add" instead of 'add' which has no effect. What am I doing wrong."> Radio button validation - Forums

Forums

Radio button validation

olaeblue 19 Jan, 2015
I have a radio button with 2 options on page 1 of a multi form

add=Add (Ignores year)
edit=Edit (Year above)

page 2 has a custom code (just to check)

<p>Form <?php echo $form->data["addedit"]; ?> --</p>


which works fine and shows add or edit as required and for edit reads the appropriate record from the DB

But the event switcher never triggers the add event, only the edit event

<?php
if ($form->data["addedit"] == 'add') {
    return "add";
   } else {
   return "edit";
   }
?>


I have tried "add" instead of 'add' which has no effect. What am I doing wrong.
olaeblue 20 Jan, 2015
Thanks Calculus, but those don't help in this case.
Max_admin 21 Jan, 2015
How do you know that the "add" event is never triggered ? how do you have the form events setup ? and how do you have the "event switcher" setup ?

You may also check the value using a "debugger" action before the "event switcher".

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
olaeblue 21 Jan, 2015
Max

I have an event switcher and some custom code <p>add</p> or <p>edit</p> as appropriate.

[attachment=0]Capture.JPG[/attachment]

edit works with both the word edit appearing and the record being loaded from the DB

the word add never appears!!

I have now tried using a dropdown with id = 1 for add and otherwise edit but adain add never triggers

<?php
if ($form->data["YearPicker"] == 1) {
    return "add";
   } else {
   return "edit";
   }
?>


The debugger sees YearPicker as 1

[attachment=1]Capture.JPG[/attachment]
but no word add
[attachment=2]add.JPG[/attachment]
but for any value not 1 I do get the edit word

[attachment=3]edit.JPG[/attachment]
olaeblue 21 Jan, 2015
BTW for all practical purposes the form is working as the add event doesn't actually do anything. But I really would like to understand what I'm doing wrong as next time I might want to actually use both events off a switcher.
GreyHead 22 Jan, 2015
Hi olaeblue,

The Event Switcher doesn't add the word 'add' to the $form->data array, it executes the actions in the 'add' sub-event - so, if the Custom Code 28 action in your form is empty then nothing will happen. Add some debug code to that action to test e.g.
<?php
$form->data['add'] = 'added';
?>


Bob
olaeblue 22 Jan, 2015
Hi Bob

Custom Code 28 has
<p>add</p>


Custom code 36 has
<p>edit</p>



This was done as a quick 'debug' to check if event was firing right and how I realized the add event was never triggered. As per screen shots 'edit' does appear on the page, 'add' doesn't

As I said even trying a different trigger php script (based on a dropdown id, instead of a radio button value) still failed to trigger the add event.
Max_admin 03 Feb, 2015
Hi olaeblue,

Did you manage to find out what's wrong ? if not then you can send me admin login details using the "Contact us" page and I can check it, just include a link to this topic in the message!

Regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
olaeblue 03 Feb, 2015
Have sent you details Max
This topic is locked and no more replies can be posted.