• Fabrik V4.4.1 is now available.

    This version corrects the Admin issue introduced by V4.4. V4.4.1 is available through the Joomla Updater or for download through your My Downloads area of our website.

    Turns out a code change intended for our 5.0dev branch inadvertantly got pushed to the 4.x branch (by me, duh!). The javascript structure in 5.0 will change considerably and part of that change took effect with the inadvertant code change.

    We have reverted the code change and released 4.4.1. V4.4 has been retracted.

    Sorry for any inconvenience.

  • A new version of Full Calendar is now available.

    See the details here

Error after upgrading to Fabrik4 Gamma3

Status
Not open for further replies.

ontarget

Active Member
Hi Just updated Fabrik from beta to Gamma3 and Joomla 4.3.0
When I go to Edit a list entry I get the following error:
0 Call to undefined method FabrikEvalClass_06ac53c3af3eead0273b64cd58614147::getFormModel()

(I have fixed the 42>43 Directory issue)

I tried unpublishing all form plugins and list plugins. However the error remains.
Do you know what the issue might be?

Fabrik Debug Shows
Call to undefined method FabrikEvalClass_06ac53c3af3eead0273b64cd58614147::getFormModel()

Call stack
#
Function Location
1 () JROOT/libraries/fabrik/fabrik/fabrik/Helpers/Php.php(69) : eval()'d code:8
2 FabrikEvalClass_06ac53c3af3eead0273b64cd58614147->doExecute() JROOT/libraries/fabrik/fabrik/fabrik/Helpers/Php.php:55
3 Fabrik\Helpers\Php::Eval() JROOT/components/com_fabrik/models/element.php:3959
4 PlgFabrik_Element->getPhpOptions() JROOT/components/com_fabrik/models/element.php:3802
5 PlgFabrik_Element->getSubOptionValues() JROOT/components/com_fabrik/models/element.php:4868
6 PlgFabrik_Element->getLabelForValue() JROOT/components/com_fabrik/models/element.php:8234
7 PlgFabrik_Element->swapValuesForLabels() JROOT/plugins/fabrik_element/calc/calc.php:85
8 PlgFabrik_ElementCalc->_getV() JROOT/plugins/fabrik_element/calc/calc.php:183
9 PlgFabrik_ElementCalc->getValue() JROOT/components/com_fabrik/models/element.php:2499
10 PlgFabrik_Element->preRenderElement() JROOT/components/com_fabrik/models/element.php:2292
11 PlgFabrik_Element->preRender() JROOT/components/com_fabrik/models/form.php:4879
12 FabrikFEModelForm->getGroupView() JROOT/components/com_fabrik/views/form/view.base.php:178
13 FabrikViewFormBase->display() JROOT/components/com_fabrik/views/form/view.html.php:39
14 FabrikViewForm->display() JROOT/components/com_fabrik/controllers/form.php:189
15 FabrikControllerForm->display() JROOT/libraries/src/MVC/Controller/BaseController.php:678
16 Joomla\CMS\MVC\Controller\BaseController->execute() JROOT/components/com_fabrik/fabrik.php:200
17 require_once() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:71
18 Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}() JROOT/libraries/src/Dispatcher/LegacyComponentDispatcher.php:73
19 Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() JROOT/libraries/src/Component/ComponentHelper.php:361
20 Joomla\CMS\Component\ComponentHelper::renderComponent() JROOT/libraries/src/Application/SiteApplication.php:208
21 Joomla\CMS\Application\SiteApplication->dispatch() JROOT/libraries/src/Application/SiteApplication.php:249
22 Joomla\CMS\Application\SiteApplication->doExecute() JROOT/libraries/src/Application/CMSApplication.php:293
23 Joomla\CMS\Application\CMSApplication->execute() JROOT/includes/app.php:61
24 require_once() JROOT/index.php:32

Thanks
 
Last edited:
Thanks for the reply
J! System Debug is on.
The list view shows a load of the usual J!Factory deprecation errors:
An error has occurred with a eval'd field - please inform the web-site owner. Debug: Eval exception : teacher_engine (id 116)::preFormatFormJoins() : $db = JFactory::getDBO(); $tr_table = $db->quoteName('user_registration'); $engine = $db->quoteName('engineSize'); $id = $db->quoteName('id'); $query = "SELECT $engine FROM $tr_table WHERE $id = '3393'"; $db->setQuery($query); $result1=$db->loadResult(); return $result1; : Joomla\CMS\Factory::getDbo() is deprecated. Load the database from the dependency injection container.

And 1 error like this:
An error has occurred with a eval'd field - please inform the web-site owner. Debug: Eval exception : completevalidationcheck (id 292)::preFormatFormJoins() : //This returns the user group and creates a validation chack on the complete button $user = JFactory::getUser(); $groups = $user->get('groups'); foreach ($groups as $group) { return $group; //echo '

Group = ' . $group . '

'; } : Joomla\CMS\Factory::getUser() is deprecated. Load the user from the dependency injection container or via Joomla\CMS\Factory::getApplication()->getIdentity().

Then it shows
Deprecated: trim(): Passing null to parameter #1 ($string) of type string is deprecated in /home/xxxx/plugins/fabrik_element/databasejoin/databasejoin.php on line 2434

The full list of errors shown as the list loads is viewable here:
https://docs.google.com/document/d/1SmLEpok0Wr0KN_O4TKbWT9RoXDI0gA0tCmGNS9bl3oI/edit?usp=sharing

When I click Edit on the list record I get the error:
0
Call to undefined method FabrikEvalClass_06ac53c3af3eead0273b64cd58614147::getFormModel()
See image
https://drive.google.com/file/d/11aHWVlsU4B6eo7Ha-CmGco7kFG_CuNlU/view?usp=share_link

The log in the joomla backend shows
error - Uncaught Throwable of type Error thrown with message "Call to undefined method FabrikEvalClass_06ac53c3af3eead0273b64cd58614147::getFormModel()". Stack trace: #0 [ROOT]/libraries/fabrik/fabrik/fabrik/Helpers/Php.php(55): FabrikEvalClass_06ac53c3af3eead0273b64cd58614147->doExecute(Array, Array) #1 [ROOT]/components/com_fabrik/models/element.php(3959): Fabrik\Helpers\Php::Eval(Array) #2 [ROOT]/components/com_fabrik/models/element.php(3802): PlgFabrik_Element->getPhpOptions(Array) #3 [ROOT]/components/com_fabrik/models/element.php(4868): PlgFabrik_Element->getSubOptionValues() #4 [ROOT]/components/com_fabrik/models/element.php(8234): PlgFabrik_Element->getLabelForValue('5', '5', true) #5 [ROOT]/plugins/fabrik_element/calc/calc.php(85): PlgFabrik_Element->swapValuesForLabels(Array) #6 [ROOT]/plugins/fabrik_element/calc/calc.php(183): PlgFabrik_ElementCalc->_getV(Array, 0) #7 [ROOT]/components/com_fabrik/models/element.php(2499): PlgFabrik_ElementCalc->getValue(Array, 0, Array) #8 [ROOT]/components/com_fabrik/models/element.php(2292): PlgFabrik_Element->preRenderElement(Array, 0) #9 [ROOT]/components/com_fabrik/models/form.php(4879): PlgFabrik_Element->preRender(0, 0, 'bootstrap') #10 [ROOT]/components/com_fabrik/views/form/view.base.php(178): FabrikFEModelForm->getGroupView('bootstrap') #11 [ROOT]/components/com_fabrik/views/form/view.html.php(39): FabrikViewFormBase->display(NULL) #12 [ROOT]/administrator/components/com_fabrik/controllers/form.php(84): FabrikViewForm->display() #13 [ROOT]/libraries/src/MVC/Controller/BaseController.php(678): FabrikAdminControllerForm->view() #14 [ROOT]/administrator/components/com_fabrik/fabrik.php(104): Joomla\CMS\MVC\Controller\BaseController->execute('view') #15 [ROOT]/libraries/src/Dispatcher/LegacyComponentDispatcher.php(71): require_once('/home/alfaonlin...') #16 [ROOT]/libraries/src/Dispatcher/LegacyComponentDispatcher.php(73): Joomla\CMS\Dispatcher\LegacyComponentDispatcher::Joomla\CMS\Dispatcher\{closure}('/home/alfaonlin...') #17 [ROOT]/libraries/src/Component/ComponentHelper.php(361): Joomla\CMS\Dispatcher\LegacyComponentDispatcher->dispatch() #18 [ROOT]/libraries/src/Application/AdministratorApplication.php(143): Joomla\CMS\Component\ComponentHelper::renderComponent('com_fabrik') #19 [ROOT]/libraries/src/Application/AdministratorApplication.php(186): Joomla\CMS\Application\AdministratorApplication->dispatch() #20 [ROOT]/libraries/src/Application/CMSApplication.php(293): Joomla\CMS\Application\AdministratorApplication->doExecute() #21 [ROOT]/administrator/includes/app.php(61): Joomla\CMS\Application\CMSApplication->execute() #22 [ROOT]/administrator/index.php(32): require_once('/home/alfaonlin...') #23 {main}

The form has 29 calc elements the majority are a bunch of sql select statements e.g:
PHP:
$db = JFactory::getDBO();
$tr_table = $db->quoteName('courses');
$tas = $db->quoteName('budget_line_id');
$c_id = $db->quoteName('id');
$query = "SELECT $tas FROM $tr_table WHERE $c_id = '{course_registrants___course_raw}'";
$db->setQuery($query);
$tas1=$db->loadResult();
return $tas1;

If I unpublish 2 specific calc elements out of the 29 the error message (when editing a record) changes to:
0
syntax error, unexpected token "{"
The code for these calc elements is as follows:
PHP:
$db = JFactory::getDBO();
$tr_table = $db->quoteName('user_registration');
$user_id = $db->quoteName('newid');
$id = $db->quoteName('id');
$query = "SELECT $user_id FROM $tr_table WHERE $id = '{course_registrants___registrant_raw}'";
$db->setQuery($query);
$result=$db->loadResult();

return $result;

and
PHP:
$db = JFactory::getDBO();
$tr_table = $db->quoteName('courses');
$ec_id = $db->quoteName('centre');
$c_id = $db->quoteName('id');
$query = "SELECT $ec_id FROM $tr_table WHERE $c_id = '{course_registrants___course_raw}'";
$db->setQuery($query);
$result=$db->loadResult();

return $result;
I can't see anything wrong in the code and the system was working with Fabrik Beta with Joomla 4.3.0.
Thanks for any other ideas you may have
 
Last edited:
I think I have found the issue:
I have a dropdown element
In Details > Advanced Tab > Eval Populate I have the following code:
PHP:
$db = JFactory::getDbo();
$course_reg = $db->quote($this->getFormModel()->data['course_registrants___course_raw']);
//return $course_reg;
$tr_table = $db->quoteName('courses');
$duration = $db->quoteName('duration');
$c_id = $db->quoteName('id');

$query = "SELECT $duration FROM $tr_table WHERE $c_id = $course_reg";
//$query = "SELECT $duration FROM $tr_table WHERE $c_id = '{course_registrants___course_id}'";

$db->setQuery($query);
$result1=$db->loadResult();

for ($x = ($result1 * 2); $x >= 1; $x--) {
    $options[] = JHTML::_('select.option', $x/2, $x/2);
}
$options[] = JHTML::_('select.option', 0, '0');
return $options;
When i unpublish this element the "0 Call to undefined method FabrikEvalClass_06ac53c3af3eead0273b64cd58614147::getFormModel()" Error goes away.
Any ideas why this error is being thrown based on the code above?
 
I dont have access to the code at the moment, but you need to read the upgrade instructions as it pertains to all user php code. JFactory needs to change to the J4 version. As for the formModel, $this is not exposed as it had been in the past, but, you should be able to get at the formModel with the variable $formModel
 
@achartier Thanks for the reply. Yes I will look at the JFactory stuff again but still haven't found the best method of writing it in J!4 and F4 (Is there a definitive guide to this yet?)
Are you suggesting I change:
PHP:
$course_reg = $db->quote($this->getFormModel()->data['course_registrants___course_raw']);
to
PHP:
$course_reg = $db->quote($formModel->data['course_registrants___course_raw']);

UPDATE:
Changing to $formModel as above works! Thanks.:)
If you can direct me to a link showing best practice for the JFactory stuff in F4 would appreciate it.
 
Did this issue get resolved re how the advanced eval'd options php code can access form data?

I the edit suggested
$res = Php::Eval(['code' => $pop, 'vars' => ["data" => $data,'formModel'=>$this->getFormModel()]]);

but replacing line 3965 on the 4zeta version of element.php, and that did not seem to provide a $formModel that I could use to access form values, the variable was still null.

In my case the element is a dbjoin element.
 
Question, why do you need the formModel? The element data all exists in the $data array and in evalOptions and such you should not be changing the form data. What is the use case?
 
Question, why do you need the formModel? The element data all exists in the $data array and in evalOptions and such you should not be changing the form data. What is the use case?

I am finding $data is null when I look at it. I put a simple 1 line code "dd($data) ;" in the advanced eval'd code section of the element and it returns null. My use case is when editing an existing entry I want to use the current value of this element in some logic for selecting which options are valid. Is there something you need to do in the aval'd code to load $data ?

I find this on J!4.4 and J!5 with Fabrik!4zeta and php 8.1.
 
Ah, found the problem, in plugins/fabrik_element/databasejoin/databasejoin.php change line 659 to the following:
Code:
if (Php::Eval(['code' => $eval, 'vars'=>['opt'=>$opt, 'data'=>$data]]) === false)
 
Many thanks, that has fixed it! For the record on F!4zeta the line to replace in databasejoin.php was actually 656
 
Status
Not open for further replies.

Members online

No members online now.
Back
Top