How to get form data into function in Custom.php

ontarget

Active Member
Hi
I am trying to get form data into /libraries/fabrik/fabrik/fabrik/Helpers/Custom.php
I have tried various methods from https://fabrikar.com/forums/index.php?wiki/php-form-plugin/

PHP:
    public static function doMyThing()
    {
    
        $hello = $formModel->_data['aaa_participant_claim___uniqueclaim_id'];
        $foo = $formModel->getElementData('aaa_participant_claim___uniqueclaim_id');
        $bar = $data['aaa_participant_claim___uniqueclaim_id'];

        //$hello = '{aaa_participant_claim___uniqueclaim_id}';
//$hello ="hello world";
        return $foo;
//return $bar;
//return $hello;

    }

I tried to call the function with a calc element - which works with a simple "hello world" and the uniqueclaim_id is a simple field element and does have a value.
Code:
return \Fabrik\Helpers\Custom::doMyThing();

But any attempts to use the formModel methods dont work (blank)

I wish to create several functions that use form data which are then called up on the fly using calc elements.
These functions will take different values from the form and a final calc element will total their ouput.
If the form data changes, then the calc elements will trigger the function calls and update a final total element.

Before i go any further with this is this possible using the /libraries/fabrik/fabrik/fabrik/Helpers/Custom.php ?

Does anyone have any examples of a function grabbing some form data.
Thanks
 
Personnaly, I use it for static functions (compute, get parameters, etc..). Nothing related to the current form.
No idea if it's possible and how.
 
I see that the $formModel is set as a private static var, but I don't see anywhere where it is set to anything. The init function is called by the autoloader which does not have access to the formModel. What you might consider doing is passing the formModel into your function when you call it.

It wasn't clear from your initial description, were the placeholders substituted? I don't see where this would happen.
 
Thanks for the replies, yes i've opted to modularise within my calc element instead and not use the Custom.php
I can see how it might be useful but I'm under too much time pressure to figure it all out!!
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top