Comparison form fields value before Event Switcher

kwok 13 Mar, 2016
Hi Bob,

Event Switcher: when $form->data['change'] == '1', do something.

Before the event switcher, the following is performed:

<?php
$form->data['change'] = '0';

if ($form->data['old_status'] != $form->data['new_status'])
{
$form->data['change'] = '1';
}
?>

The event is triggered even the content of both fields are the same.

Then I tried:
<?php
$form->data['change'] = '0';

if ($form->data['old_status'] != $form->data['old_status'])
{
$form->data['change'] = '1';
}
?>

The event is triggered even they are same fields.

I changed the operator for != to <>, the result is the same.

Thanks,
kwok
GreyHead 13 Mar, 2016
Hi kwok,

You have to debug your custom code. You haven't posted the code from the Event Switcher here as far as I can see so it's hard to tell exactly what is happening.

Using '0' and '1' as strings is an odd and unreliable way to do comparisons. Better to use true and false (with no quotes).

Bob

PS You can include this code in the Event Switcher, you don’t need an extra Custom Code action before it.
This topic is locked and no more replies can be posted.

VPS & Email Hosting 20% discount
hostinger