$data array is empty in form view after installing latest update to Fabrik

Status
Not open for further replies.

usdc-or

Member
I've got a php eval populated checkbox on a form (many elements like this actually), that rely on the $data['tablename__elementname'] paradigm to retrieve data because it is in an external script (it's used all over the place so I didn't want to have to edit it 100 times each time it needed changed). After the update the array $data is empty so nothing's working right. I've had this set up this way for many years... I'm so upset that it's not working now and I can't find what I should use instead of $data.

The included script is loading fine, just all my variables are null becase $data returns empty array. Please help!
 
Update from where to where?

WIKI says for dropdowns
Eval - PHP Code to create options, should return an array of JHTML select.options. Get data from other elements via $this->getFormModel()->data['table___element'] resp. $this->getFormModel()->data['table___element_raw']
It's the same for checkboxes.
So something like
$data = $this->getFormModel()->data;
at the start of your script may do.

Edit:
better change all $data[ to $this->getFormModel()->data[
or do at least some defensive coding like
$o_data = $data;//at the start of your script
...
$data = $o_data;//at the end of your script

for not to override $data which may be used by Fabrik at other places.
 
Last edited:
Thanks for your quick response; I just came back in to say that I added "$data= $this->getFormModel()->data;" as the first line in my checkbox eval box after comparing the code for the calc plugin and the checkbox plugin, and that got things working again. In the past and in other elements, like calc, $data has been populated with the form's data (can see with print_r($data);exit; in calc), but after the update $data used in the checkbox element is empty.

To be clear, I was just using Fabrik's "$data" variable, so no danger of overriding.

I only updated from 3.9 to 3.9.2. I realized you probably wanted that info, but I didn't have it in front of me yesterday. I'm glad it seems to be just the checkbox element (and possibly dropdown?). I only use this option creating thing for these two applications, not all over the place. Yesterday afternoon I was so afraid that everywhere I had been using $data['tablename__elementname'] paradigm wasn't working, and that is a lot of places--php scripts, email templates, calc elements... so many.

Thanks again!
 
Status
Not open for further replies.
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top