Solved "Uncaught TypeError: document.getElements(...)[0] is undefined" in form.js with joomla 4.4 (fixed)

ptrovatelli

New Member
Got that error when trying to load a form that was defined in previous versions of joomla / fabrik:
the page is blank and javascript console says:
Uncaught TypeError: document.getElements(...)[0] is undefined

It is in form.js line 897 (got the unminified version of the file by activating joomla and fabrik debug)
addElements: function (a) { /* * Store the newly added elements so we can call attachedToForm only on new elements. * Avoids issue with cdd in repeat groups resetting themselves when you add a new group */ var added = [], i = 0; a = $H(a); 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;

The error is on this line:
if (document.getElements('input[name=rowid]')[0].value != "" && el[0] != 'FbLockrow') {


Everything worked with :
- joomla 4.3.2 / fabrik 4.0gamma3

Got the error with the below versions so it makes me think it's an issue with joomla 4.4 :
- joomla 4.4.0 / fabrik 4.0gamma3
- joomla 4.4.3 / fabrik 4.0gamma3
- joomla 4.4.3 / fabrik 4.0 (final)
 
Just did another test:
- restored my joomla 4.3.2 / fabrik 4.0gamma3 backup (last known working version)
- upgraded to joomla 4.3.3: OK
- upgraded to joomla 4.3.4: OK
- upgraded to joomla 4.4.0: still OK!

So it's not just joomla 4.4.0. Something else happened which broke something in fabrik.
Will post more when I find a clue of what could have happened.
The thing is, that part of my website is not a feature I use all the time. last time I used it was in august 2023 (working backup from november 2023) and I realize just now that it's broken.
There is the same issue in all the fabrik forms i've tried so it seems pretty generalized
 
Last edited:
OK I got it, my bad!
It is a change that I did in gantry. I did some housekeeping trying to find out which gantry outline were really useful, and which were not. So I deactivated the elements present in the "by default" outline.

I understand now that this configures what is allowed to be displayed on the websites for pages that are not ruled by a specific gantry outline. It is the case for those fabrik forms that I don't look at on a daily basis.

So what happened is that there was pretty much no content displayed, which is why fabrik failed;
When comparing to a working version of the site, this block for example was completely misssing (thus generating the error about the input / rowid element)

HTML:
<div class="fabrikHiddenFields">
    <input type="hidden" name="listid" value="14" />
<input type="hidden" name="listref" value="14" />
<input type="hidden" name="rowid" value="" />
<input type="hidden" name="Itemid" value="171" />
<input type="hidden" name="option" value="com_fabrik" />
<input type="hidden" name="task" value="form.process" />
<input type="hidden" name="isMambot" value="" />
<input type="hidden" name="formid" value="15" />
<input type="hidden" name="returntoform" value="0" />
<input type="hidden" name="fabrik_referrer" value="" />
<input type="hidden" name="fabrik_ajax" value="0" />
<input type="hidden" name="package" value="fabrik" />
<input type="hidden" name="packageId" value="" />
<input type="hidden" name="nodata" value="0" />
<input type="hidden" name="19a3d557cf7a810d0e2b5ce7ea548396" value="1">
<input type="hidden" name="format" value="html" />
<input type="hidden" name="fabrik_repeat_group[26]" value="1" id="fabrik_repeat_group_26_counter" />
<input type="hidden" name="fabrik_repeat_group_added[26]" value="0" id="fabrik_repeat_group_26_added" /></div>
<div class="fabrikActions form-actions mt-3">
    <div class="btn-toolbar justify-content-between" role="toolbar" aria-label="Fabrik Actions">
                    <div class="btn-group" role="group" airia-label="Submit-Apply-Copy">

Fixed by re-enabling gantry default outline elements
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top