This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.
nylson.bryan25052
I followed this guide to create a widget base for backend. In this section:
$myWidget = new MyWidgetClass($this);
$myWidget->alias = 'myWidget';
$myWidget->bindToController();
. How pass a variable from controller to widget?
Thanks
Last updated
Tschallacka
in the widget $this->controller->publicFunctionName()
or $this->controller->publicFieldName
are options.
You can also set the config, or make a method in the widget.
The widget is a normal class, you can just do normal php stuff with it, especially if you initialise it the way you do.
class MyWidgetClass() {
protected $myOptions = [
'foo'=>1
'bar' =>2
];
public function setOptions(array $options) {
$this->myOptions = $options;
}
}
Last updated
1-2 of 2