Official Support Area, Q&As, Discussions, Suggestions and Bug reports.
Forum's Guidelines
Hi Stefan,
You could set/access $this and $this->params (array type) in both the controller/setup file and the view file of a report. So a way to pass variables is:
//MyReport.php
$this->var1 = $var1;
$this->params["var2"] = $var2;
//MyReport.view.php
$var1 = $this->var1;
$var2 = $this->params["var2"];
Let us know if we understand your question correctly. Thanks!
In my case I need to pass value from index.php to MyReport.php and then to MyReport.view.php. The code that is index.php is as follows:
<? php
require_once "MyReport.php";
$tab = $ _GET ['table'];
$cam = $ _GET ['field'];
$report = new MyReport;
$report-> run() -> render();
I need to pass $tab and $cam variables to MyReport.php and then to MyReport.view.php; How can I do this?
I get an error when accessing params on view, beacuse the property "params" is protected on the object. So, on the view, the code
<?php echo $report->params["id"] ?>
throws the error.
The same occurs for "dataSources" property, but fortunately we have a method dataSources("name") for accessing this array, and this doen't happen with the params array. What am I missing?
(note: $report is the object on views because I use blade extension)
Let KoolReport help you to make great reports. It's free & open-source released under MIT license.
Download KoolReport View demo