bggann
Active Member
Fabrik has the ability to load a custom helper file - as an alternative to using "require" or "require_once" in calcs.
If you put a file called Custom.php in /libraries/fabrik/fabrik/helpers and then call
FabrikCustom::doMyThing() in your code Fabrik will look in custom.php for the function doMyThing() and execute it. (there is an example file in there called CustomSample.php)
My challenge is this.
I call a function inside Custom.php and that function calls another function in Custom.php.
It does not seem to work - it can't find the 2nd function. Is there a way to do that?
Example (silly example code)
My calc element is
$parameter = '{placeholder}';
$answer = FabrikCustom::doThingOne($parameter);
return $answer;
In custom.php are the two functions (this is not the full custom.php)
---------
public static function doThingOne($parameter) {
public static function doThingTwo($example) {
-----------
What I want to happen is
-> The calc element calle doThingOne()
-> doThingOne() calls doThingTwo()
-> doThingTwo() returns an answer to doThingOne
-> doThingOne() returns an answer to the calc
-> The calc returns to the form.
What does happen
-> doThingOne() hangs with a spinner on the call to doThingTwo()
It appears that doThingTwo() is not defined in the context of doThingOne()
Any way around this?
If you put a file called Custom.php in /libraries/fabrik/fabrik/helpers and then call
FabrikCustom::doMyThing() in your code Fabrik will look in custom.php for the function doMyThing() and execute it. (there is an example file in there called CustomSample.php)
My challenge is this.
I call a function inside Custom.php and that function calls another function in Custom.php.
It does not seem to work - it can't find the 2nd function. Is there a way to do that?
Example (silly example code)
My calc element is
$parameter = '{placeholder}';
$answer = FabrikCustom::doThingOne($parameter);
return $answer;
In custom.php are the two functions (this is not the full custom.php)
---------
public static function doThingOne($parameter) {
$example = $parameter * 2;
$new_answer = FabrikCustom::doThingTwo($example);
return $new_answer;
}$new_answer = FabrikCustom::doThingTwo($example);
return $new_answer;
public static function doThingTwo($example) {
$stuff_I_did = $example * 2;
return $stuff_I_did;
}return $stuff_I_did;
-----------
What I want to happen is
-> The calc element calle doThingOne()
-> doThingOne() calls doThingTwo()
-> doThingTwo() returns an answer to doThingOne
-> doThingOne() returns an answer to the calc
-> The calc returns to the form.
What does happen
-> doThingOne() hangs with a spinner on the call to doThingTwo()
It appears that doThingTwo() is not defined in the context of doThingOne()
Any way around this?