SOLVED: Condition fails on email form plugin

Status
Not open for further replies.

dimoss

Well-Known Member
Joomla 4.2.9
Fabrik #4 Gamma 3
Cassiopeia
vanilla J & F installation

Hi,

I use the email form plugin to send email on Edit when a field changes on an existing record.
On Options->Condition I use the following which worked fine in F3.9 (PHP 7.4) as below:

$origData = $formModel->getOrigData();
$old = $origData[0]>fab_players___valid_raw;
$new = '{fab_players___valid_raw}';
if (($old != $new) && ($old == 0))
{return true;} //email will be send
else
{return false;} //email will not be send

In F4 returns the following error:
0 Call to a member function getOrigData() on null

The email fails to be sent but the field changes.

Thanks in advance for you help.
 
I think you can use directly $origData, it should be there already.
(i.e. remove $origData = $formModel->getOrigData();, $formModel has still to be added to the params for the new Php::eval)

Check if you get something with _raw
There's some issue with raw values and conditions (but I didn't dig into it)
https://fabrikar.com/forums/index.php?threads/problem-with-conditional-validation.53824/#post-281194

Removing $origData = $formModel->getOrigData(); and either with or without _raw it returns NULL and not the $origData.
 
$origData->fab_players___valid_raw; without [0] ?

Or components/com_fabrik/models/plugin.php line 1138
$res = Php::Eval(['code' =>$condition, 'vars'=>['data'=>$data, 'origData' => $origData, 'formModel' => $formModel]]);
 
$origData->fab_players___valid_raw; without [0] ?

Or components/com_fabrik/models/plugin.php line 1138
$res = Php::Eval(['code' =>$condition, 'vars'=>['data'=>$data, 'origData' => $origData, 'formModel' => $formModel]]);

With or without [0] returns NULL

However your fix on components/com_fabrik/models/plugin.php line 1138 did the trick and fixed the issue so that i was able to use my original code slightly changed remoming _raw. I share it here just in case someone else wants something similar.

$origData = $formModel->getOrigData();
$old = $origData[0]->fab_players___valid;
$new = '{fab_players___valid_raw}';
//var_dump($new,$old);
//exit;
if (($old != $new) && ($old == 0))
{return true;} //email will be send
else
{return false;} //email will not be send

Thanks @troester
 
Just for the records:
$origData['fab_players___valid'] or _raw should do (but both holding the raw value).
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top