Cannot read an undeclared property PagePresenter::$model
Notice: This thread is very old.
- Jan Tvrdík
- Nette guru | 2595
ivanscm: How do you expect the code should work? Nette does
not define model
property so if you want to use it you must specify
it yourself. For example you may add the following code
to BasePresenter
class BasePresenter extends ...
{
public $model;
protected function startup()
{
parent::startup();
$this->model = new YourModel(); // you must create class YourModel first
}
}
Another solution could be to create getter.
class BasePresenter extends ...
{
private $model;
public function getModel()
{
if ($this->model === NULL) $this->model = new YourModel();
return $this->model;
}
}