• Fabrik4.5.1 for Joomla5.2.4

    Fabrik4.5.1 is out. This update is needed for J!5.2.4

    See Announcements

Fixed Digsig strange behavior

Ninpo

Member
I am a longtime user of fabrik, since Joomla 3.0. I have written many custom applications with Fabrik and many custom templates.

I am currently migrating a project from Joomla 3.x to Joomla 5.2. Everything is going great except the Digsig plugin. I do have custom templates I am using but the actual signature will not render in the details view. I traced this down to to the digsig.js file not being called.

I inserted a very short code block to see if this Javascript was being called under the initialize function
Code:
define(['jquery', 'fab/element'], function (jQuery, FbElement) {
    window.FbDigsig = new Class({
        Extends   : FbElement,
        initialize: function (element, options) {
            console.log('we are here');

When I use the default bootstrap templates I see the console message but when I use my templates I do not see this message. I decided to try figure out why this was occurring. I took a copy of the default details bootstrap templates to play with. This project "list/form" has 13 groups in it with id numbers 96 - 109. The Digsig component sits in group id 109. If I manually exclude any published group in this form in the default.php file in my copy of the bootstrap templates, then the digsig.js does not get called. I tested this as follows;

The code below will not call the digsig.js file because I excluded group id 96.
Code:
foreach ($this->groups as $group) :
   $this->group = $group;
    $validIDS = Array(109);

    for($i = 97; $i < 109; $i++) {
        array_push($validIDS, $i);
    }

    if(!in_array($group->id, $validIDS)) { continue; }

This code will work because I included group id 96 BUT it does not matter which is excluded, could be 101, 97, 98, etc...
Code:
foreach ($this->groups as $group) :
   $this->group = $group;
    $validIDS = Array(109);

    for($i = 96; $i < 109; $i++) {
        array_push($validIDS, $i);
    }

    if(!in_array($group->id, $validIDS)) { continue; }

Can anyone share some insight why the digsig plugin will not load the corresponding Javascript file, making the signature not render, if an unrelated group is excluded from the template?
 
Which exact Fabrik version are you running?

If it's running with Fabrik's default bootstrap template it must be your custom template.
You can't use F3 template.
 
Thank you. I am running Fabrik 4.5. As stated in my tests above, I replicated the issue in the default bootstrap template by putting constraints around the the which group "based on id", I was allowing to render. I did this to eliminate my custom templates from the equation. This is the only plugin having this issue.
 
I am running Jooma 5.2.3 with PHP Version 8.3.16. I am currently running this in a sandbox "docker" environment of our website on my local desktop to figure out this issue. The main public facing site is also dockerized. The site is also running Koleti template from Rocket Theme, if this helps. I have seen strange behavior from Rocket Theme and Gantry 5, that I have had to figure ways around. Unfortunately, I have to stick with this template for now but it could be a contributing factor as Gantry had an issue with 2FA that I had to find a work around for. It's not so far fetched that there could be other issues as well, which is what I am starting to suspect.
 
Ok, I figured out the issue here. It's actually in form.js on line 897. In chrome developer tools, I was getting the following error ONLY when I excluded a form group using a slightly modified version of the bootstrap templates.

1738876828749.png


The line that is causing this error is;
a.each(function (elements, gid) {
elements.each(function (el) {
if (typeOf(el) === 'array') {
if (typeOf(document.id(el[1])) === 'null') {
/* Some elements may not exist if this is a new record, specifically the lockrow element */
if (document.getElements('input[name=rowid]')[0].value != "" && el[0] != 'FbLockrow') {
fconsole('Fabrik form::addElements: Cannot add element "' + el[1] +
'" because it does not exist in HTML.');
}
return;
}

I modified this line as such;
a.each(function (elements, gid) {
elements.each(function (el) {
if (typeOf(el) === 'array') {
if (typeOf(document.id(el[1])) === 'null') {
/* Some elements may not exist if this is a new record, specifically the lockrow element */
if ((document.getElements('input[name=rowid]')[0]) && (document.getElements('input[name=rowid]')[0].value != "") && el[0] != 'FbLockrow') {
fconsole('Fabrik form::addElements: Cannot add element "' + el[1] +
'" because it does not exist in HTML.');
}
return;
}

Essentially, it was trying to grab the value parameter when the array element was null or undefined. I added a small check for this and now the signature renders on the page.

How do we get this minor modification into the source repo? I do not want this change to be erased when we update the component.
 

Members online

No members online now.
Back
Top