Two email plugins on a form, only one 'Email Sent Field' working

mondejars

Member
Hi all,

I am having a weird issue when I try to use two form email plugins, everything works OK (conditions, templates, attachments, etc.) but when I try to use the 'Email sent Field' on both of them, both pointing to different YesNo elements, only the second YesNo element is working for both email plugins.

So I have a dropdown to get the conditions for email sending, let's say 1 and 2.

If I set the dropdown to 2, it works fine, it updates the 'Email sent field' YesNo element as it should but if I set dropdown on 1, it sends the mail and everything but it updates the second 'Email sent field' YesNo element, not the one it has assigned

Has anyone had this problem before?
I have been searching the forum but there are just a few references about the 'Email sent field' functionality, any help will be much welcomed.

Thanks in advance.

EDIT: Latest Joomla version, updated from GitHub yesterday, pretty clean protostar template.
 
Last edited:
Ok, I have a guess about what is happening, having a look at /plugins/fabrik_form/email/email.php, I think I have found the 'Email sent field', lines 441 to 456.

Code:
    protected function alreadySent()
    {
        $params      = $this->getParams();
        $updateField = $params->get('email_update_field');
        if (!empty($updateField))
        {
            $updateField .= '_raw';
            $updateEl    = StringHelper::safeColNameToArrayKey($updateField);
            $updateVal   = ArrayHelper::getValue($this->data, $updateEl, '');
            $updateVal   = is_array($updateVal) ? $updateVal[0] : $updateVal;

            return !empty($updateVal);
        }

        return false;
    }
and lines 846 to 856:
Code:
private function updateRow()
{
$params = $this->getParams();
$updateField = $params->get('email_update_field');
$rowid = $this->data['rowid'];
if (!empty($updateField) && !empty($rowid))
{
$this->getModel()->getListModel()->updateRow($rowid, $updateField, '1');
}

My guess is if there are two email form plugins running
Code:
$this->getModel()->getListModel()->updateRow($rowid, $updateField, '1');
it would be the same field for both so is updating just the last one being processed.

Obviously, due to my little knowledge about coding, I could be perfectly wrong but, can anyone throw some light on this?
Cheers.
 
Last edited:
Confirmed.
No idea why but it seems while running the "first" email plugin getParams in updateRow is fetching the params of the "last" email plugin (I tested with 4, only the first one is doing wrong).
I have a solution but not sure if it has side effects.
https://github.com/Fabrik/fabrik/pull/2241
 
Just in case it helps, after amending the code on my email.php, it works fine until 'Attach as PDF' is enabled on the first plugin, then starts having the same issue again o_O No problems when enabling 'Attach as PDF' on the last plugin though.
 
Last edited:
Forget about the post above (I've delete the post).

Update_field is working on my site also with PDF attachtment (with the pull request modification).
 
Mine is working just when I set everything new for the 1st time, after that I still have the error when attaching PDF on the first plugin.

Thank you for taking the time to look at it, I will keep investigating what's wrong with my site.

Cheers.
 
Last edited:
Just a quick post in case anyone is having a similar issue, I have found a workaround.

It's pretty basic and not very elegant but it works, using email send conditions pointing to your desired 'Email sent' elements (not the ones in Email plugin feature but in the condition box) and using Upsert plugin to update those same elements with some conditions can recreate what the 'Email sent field' does. Works pretty well and no issues at all.

Cheers.
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top